summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
Diffstat (limited to 'source3')
-rw-r--r--source3/lib/util_file.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/source3/lib/util_file.c b/source3/lib/util_file.c
index 1e0d880e83..03246cad8e 100644
--- a/source3/lib/util_file.c
+++ b/source3/lib/util_file.c
@@ -285,9 +285,6 @@ static char **file_lines_parse(char *p, size_t size, int *numlines)
return NULL;
}
memset(ret, 0, sizeof(ret[0])*(i+2));
- if (numlines) {
- *numlines = i;
- }
ret[0] = p;
for (s = p, i=0; s < p+size; s++) {
@@ -301,6 +298,15 @@ static char **file_lines_parse(char *p, size_t size, int *numlines)
}
}
+ /* remove any blank lines at the end */
+ while (i > 0 && ret[i-1][0] == 0) {
+ i--;
+ }
+
+ if (numlines) {
+ *numlines = i;
+ }
+
return ret;
}