From 9cf8d5481b7dc75b18f0375dc2c1f79295214b84 Mon Sep 17 00:00:00 2001 From: Kresten Krab Thorup Date: Mon, 20 Sep 1993 10:27:23 +0000 Subject: [PATCH] (objc_read_string): Allocate n+1 chars instead of just n. From-SVN: r5371 --- gcc/objc/archive.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gcc/objc/archive.c b/gcc/objc/archive.c index 867b74977f3..ad822fad53f 100644 --- a/gcc/objc/archive.c +++ b/gcc/objc/archive.c @@ -627,10 +627,10 @@ objc_read_string (struct objc_typed_stream* stream, unsigned int nbytes = buf[0]&_B_VALUE; len = __objc_read_nbyte_uint(stream, nbytes, &nbytes); if (len) { - (*string) = (char*)__objc_xmalloc(nbytes); + (*string) = (char*)__objc_xmalloc(nbytes+1); if (key) hash_add (&stream->stream_table, (void*)key, *string); - len = (*stream->read)(stream->physical, *string, buf[0]&_B_VALUE); + len = (*stream->read)(stream->physical, *string, nbytes); (*string)[nbytes] = '\0'; } } -- 2.30.2