Commit 9cf8d548 by Kresten Krab Thorup

(objc_read_string): Allocate n+1 chars instead of just n.

From-SVN: r5371
parent 5738a80a
...@@ -627,10 +627,10 @@ objc_read_string (struct objc_typed_stream* stream, ...@@ -627,10 +627,10 @@ objc_read_string (struct objc_typed_stream* stream,
unsigned int nbytes = buf[0]&_B_VALUE; unsigned int nbytes = buf[0]&_B_VALUE;
len = __objc_read_nbyte_uint(stream, nbytes, &nbytes); len = __objc_read_nbyte_uint(stream, nbytes, &nbytes);
if (len) { if (len) {
(*string) = (char*)__objc_xmalloc(nbytes); (*string) = (char*)__objc_xmalloc(nbytes+1);
if (key) if (key)
hash_add (&stream->stream_table, (void*)key, *string); 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'; (*string)[nbytes] = '\0';
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment