mojoshader.c
changeset 1052 0ac978521113
parent 1050 56b06b1ebb27
child 1054 63dd1a46ce13
--- a/mojoshader.c	Thu Jun 02 14:49:30 2011 -0400
+++ b/mojoshader.c	Thu Jun 09 01:56:10 2011 -0400
@@ -6940,13 +6940,17 @@
     if ((pos + 16 + (info->member_count * 8)) >= bytes)
         return 0;  // corrupt CTAB.
 
-    const size_t len = sizeof (MOJOSHADER_symbolStructMember) *
-                        info->member_count;
-
-    info->members = (MOJOSHADER_symbolStructMember *) Malloc(ctx, len);
-    if (info->members == NULL)
-        return 1;  // we'll check ctx->out_of_memory later.
-    memset(info->members, '\0', len);
+    if (info->member_count == 0)
+        info->members = NULL;
+    else
+    {
+        const size_t len = sizeof (MOJOSHADER_symbolStructMember) *
+                            info->member_count;
+        info->members = (MOJOSHADER_symbolStructMember *) Malloc(ctx, len);
+        if (info->members == NULL)
+            return 1;  // we'll check ctx->out_of_memory later.
+        memset(info->members, '\0', len);
+    } // else
 
     int i;
     const uint32 *member = (const uint32 *)((const uint8 *) (&typeptr[6]));