glsl: don't allocate 0-length children array in slang_operation_copy()
authorBrian Paul <brianp@vmware.com>
Thu, 18 Jun 2009 22:57:23 +0000 (16:57 -0600)
committerBrian Paul <brianp@vmware.com>
Fri, 26 Jun 2009 19:16:32 +0000 (13:16 -0600)
src/mesa/shader/slang/slang_compile_operation.c

index 310a46b6454a6f48ae209b10635f5afc7e97d71d..730cc0691299e6423991478218dc6b16d1dd1ea1 100644 (file)
@@ -119,11 +119,13 @@ slang_operation_copy(slang_operation * x, const slang_operation * y)
    if (!slang_operation_construct(&z))
       return GL_FALSE;
    z.type = y->type;
-   z.children = (slang_operation *)
-      _slang_alloc(y->num_children * sizeof(slang_operation));
-   if (z.children == NULL) {
-      slang_operation_destruct(&z);
-      return GL_FALSE;
+   if (y->num_children > 0) {
+      z.children = (slang_operation *)
+         _slang_alloc(y->num_children * sizeof(slang_operation));
+      if (z.children == NULL) {
+         slang_operation_destruct(&z);
+         return GL_FALSE;
+      }
    }
    for (z.num_children = 0; z.num_children < y->num_children;
         z.num_children++) {
@@ -285,4 +287,3 @@ slang_operation_add_children(slang_operation *oper, GLuint num_children)
    }
 }
 
-