summaryrefslogtreecommitdiffstats
path: root/edit.c
diff options
context:
space:
mode:
authorThomas Roessler <roessler@does-not-exist.org>2001-12-17 10:08:18 +0000
committerThomas Roessler <roessler@does-not-exist.org>2001-12-17 10:08:18 +0000
commite86e391d6ca525a8dd02ad4f242bf89b26b8319a (patch)
tree9586f6fd2b61f77527c3689a2974023a81cf7be0 /edit.c
parent31032c82e5e8110d09edd6c8b88bcfb7737e947d (diff)
Fix a memory allocation bug. #917.
Diffstat (limited to 'edit.c')
-rw-r--r--edit.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/edit.c b/edit.c
index 07262fde..bbcc3e55 100644
--- a/edit.c
+++ b/edit.c
@@ -79,6 +79,9 @@ be_snarf_data (FILE *f, char **buf, int *bufmax, int *buflen, int offset,
safe_realloc ((void **)&buf, sizeof (char *) * (*bufmax += 25));
buf[(*buflen)++] = safe_strdup (tmp);
}
+ if (buf && *bufmax == *buflen) { /* Do not smash memory past buf */
+ safe_realloc ((void **)&buf, sizeof (char *) * (++*bufmax));
+ }
if (buf) buf[*buflen] = NULL;
return (buf);
}