NUL-terminate bytevectors too.
authorTaylor R Campbell <campbell@mumble.net>
Wed, 9 Jan 2019 03:46:26 +0000 (03:46 +0000)
committerTaylor R Campbell <campbell@mumble.net>
Wed, 9 Jan 2019 03:56:35 +0000 (03:56 +0000)
This shouldn't be necessary but we use these for primitive names with
routines that expect them to be NUL-terminated, so this is more
convenient until we either length-delimit the primitive names or
explicitly NUL-terminate them or whatever.

src/microcode/bytevector.c

index 6ef990ba9a10856e8f7dc181e59978ac75ef8142..09dfd8b46d97630d87627f506447b0ea25a36284 100644 (file)
@@ -56,9 +56,10 @@ allocate_bytevector (unsigned long nbytes)
   SCHEME_OBJECT result
     = (allocate_non_marked_vector
        (TC_BYTEVECTOR,
-        ((BYTES_TO_WORDS (nbytes)) + BYTEVECTOR_LENGTH_SIZE),
+        ((BYTES_TO_WORDS (nbytes + 1)) + BYTEVECTOR_LENGTH_SIZE),
         true));
   SET_BYTEVECTOR_LENGTH (result, nbytes);
+  ((BYTEVECTOR_POINTER (result)) [nbytes]) = '\0';
   return (result);
 }