summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRay Donnelly <mingw.android@gmail.com>2014-02-02 10:51:05 -0500
committerPaul Smith <psmith@gnu.org>2014-02-08 16:01:10 -0500
commite1863c05d82096aa2bfcddb436da1b54a41369e3 (patch)
treec1a3ba1efc937120ca3a9c216999815ea4b8cf65
parentb981bfd197eb767e93739908e4ec49406c314894 (diff)
downloadgunmake-e1863c05d82096aa2bfcddb436da1b54a41369e3.tar.gz
* output.c: Ensure space for final nul byte in fmtbuf.
Copyright-paperwork-exempt: yes
-rw-r--r--output.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/output.c b/output.c
index 000e241..b2584f1 100644
--- a/output.c
+++ b/output.c
@@ -591,14 +591,14 @@ static struct fmtstring
static char *
get_buffer (size_t need)
{
- /* Make sure we have room. */
+ /* Make sure we have room. NEED includes space for \0. */
if (need > fmtbuf.size)
{
fmtbuf.size += need * 2;
fmtbuf.buffer = xrealloc (fmtbuf.buffer, fmtbuf.size);
}
- fmtbuf.buffer[need] = '\0';
+ fmtbuf.buffer[need-1] = '\0';
return fmtbuf.buffer;
}
@@ -629,7 +629,7 @@ message (int prefix, size_t len, const char *fmt, ...)
strcat (p, "\n");
- assert (fmtbuf.buffer[len] == '\0');
+ assert (fmtbuf.buffer[len-1] == '\0');
outputs (0, fmtbuf.buffer);
}
@@ -660,7 +660,7 @@ error (const gmk_floc *flocp, size_t len, const char *fmt, ...)
strcat (p, "\n");
- assert (fmtbuf.buffer[len] == '\0');
+ assert (fmtbuf.buffer[len-1] == '\0');
outputs (1, fmtbuf.buffer);
}
@@ -692,7 +692,7 @@ fatal (const gmk_floc *flocp, size_t len, const char *fmt, ...)
strcat (p, stop);
- assert (fmtbuf.buffer[len] == '\0');
+ assert (fmtbuf.buffer[len-1] == '\0');
outputs (1, fmtbuf.buffer);
die (2);