Index: binutils/binutils/objcopy.c |
diff --git a/binutils/binutils/objcopy.c b/binutils/binutils/objcopy.c |
index 2048827f8e17f21d9bdf06545466247f7b2b1fc2..e0cac197f1ff9c15e104f31422a34a643d221a2f 100644 |
--- a/binutils/binutils/objcopy.c |
+++ b/binutils/binutils/objcopy.c |
@@ -1237,7 +1237,7 @@ add_redefine_syms_file (const char *filename) |
filename, strerror (errno)); |
bufsize = 100; |
- buf = (char *) xmalloc (bufsize); |
+ buf = (char *) xmalloc (bufsize + 1 /* For the terminating NUL. */); |
lineno = 1; |
c = getc (file); |
@@ -1254,7 +1254,7 @@ add_redefine_syms_file (const char *filename) |
if (len >= bufsize) |
{ |
bufsize *= 2; |
- buf = (char *) xrealloc (buf, bufsize); |
+ buf = (char *) xrealloc (buf, bufsize + 1); |
} |
c = getc (file); |
} |
@@ -1280,7 +1280,7 @@ add_redefine_syms_file (const char *filename) |
if (len >= bufsize) |
{ |
bufsize *= 2; |
- buf = (char *) xrealloc (buf, bufsize); |
+ buf = (char *) xrealloc (buf, bufsize + 1); |
} |
c = getc (file); |
} |