summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source4/lib/util/util_file.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/source4/lib/util/util_file.c b/source4/lib/util/util_file.c
index 5d7ec40b30..887efb9836 100644
--- a/source4/lib/util/util_file.c
+++ b/source4/lib/util/util_file.c
@@ -263,7 +263,6 @@ static char **file_lines_parse(char *p, size_t size, int *numlines, TALLOC_CTX *
talloc_steal(ret, p);
memset(ret, 0, sizeof(ret[0])*(i+2));
- if (numlines) *numlines = i;
ret[0] = p;
for (s = p, i=0; s < p+size; s++) {
@@ -275,6 +274,13 @@ static char **file_lines_parse(char *p, size_t size, int *numlines, TALLOC_CTX *
if (s[0] == '\r') s[0] = 0;
}
+ /* remove any blank lines at the end */
+ while (i > 0 && ret[i-1][0] == 0) {
+ i--;
+ }
+
+ if (numlines) *numlines = i;
+
return ret;
}