From: Kresten Krab Thorup Date: Mon, 20 Sep 1993 10:27:23 +0000 (+0000) Subject: (objc_read_string): Allocate n+1 chars instead of just n. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=9cf8d5481b7dc75b18f0375dc2c1f79295214b84;p=gcc.git (objc_read_string): Allocate n+1 chars instead of just n. From-SVN: r5371 --- 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'; } }