(objc_read_string): Allocate n+1 chars instead of just n.
authorKresten Krab Thorup <krab@gcc.gnu.org>
Mon, 20 Sep 1993 10:27:23 +0000 (10:27 +0000)
committerKresten Krab Thorup <krab@gcc.gnu.org>
Mon, 20 Sep 1993 10:27:23 +0000 (10:27 +0000)
From-SVN: r5371

gcc/objc/archive.c

index 867b74977f3bbd5719869d84087c07c5eda4e846..ad822fad53f025a483b4d8d4b72209e9e429a087 100644 (file)
@@ -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';
          }
        }