Make sure assembly source in test program is null-terminated.
authorRyan C. Gordon <icculus@icculus.org>
Fri, 12 Dec 2008 04:22:33 -0500
changeset 509 88c18d64e95b
parent 508 f45abd96ad7b
child 510 f4433db86f6e
Make sure assembly source in test program is null-terminated.
finderrors.c
--- a/finderrors.c	Fri Dec 12 04:10:25 2008 -0500
+++ b/finderrors.c	Fri Dec 12 04:22:33 2008 -0500
@@ -71,7 +71,7 @@
     } // if
 
     static unsigned char buf[1024 * 256];
-    int rc = fread(buf, 1, sizeof (buf), io);
+    int rc = fread(buf, 1, sizeof (buf)-1, io);
     fclose(io);
     if (rc == -1)
     {
@@ -83,6 +83,7 @@
     {
         const MOJOSHADER_parseData *a;
 
+        buf[rc] = '\0';  // make sure the source is null-terminated.
         a = MOJOSHADER_assemble((char *) buf, 0, 0, 0);
         if (a->error)
         {