]> granicus.if.org Git - neomutt/commitdiff
Fix a memory allocation bug. #917.
authorThomas Roessler <roessler@does-not-exist.org>
Mon, 17 Dec 2001 10:08:18 +0000 (10:08 +0000)
committerThomas Roessler <roessler@does-not-exist.org>
Mon, 17 Dec 2001 10:08:18 +0000 (10:08 +0000)
edit.c

diff --git a/edit.c b/edit.c
index 07262fdead6c3c70b799ed7dac605d3777ef5443..bbcc3e5553344dcb75211728674a41eb50a47b6f 100644 (file)
--- 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);
 }