diff options
author | Brian Paul <[email protected]> | 2009-06-18 16:57:23 -0600 |
---|---|---|
committer | Brian Paul <[email protected]> | 2009-06-26 13:16:32 -0600 |
commit | c1f74a6734494d0531eb7dc844bb83e7d9c9f1fa (patch) | |
tree | b9f143fadf6f6772f47821ebc4726b53eef36572 | |
parent | f38872473cc035487dbe265a520cb4c6eb3cc81c (diff) |
glsl: don't allocate 0-length children array in slang_operation_copy()
-rw-r--r-- | src/mesa/shader/slang/slang_compile_operation.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/mesa/shader/slang/slang_compile_operation.c b/src/mesa/shader/slang/slang_compile_operation.c index 310a46b6454..730cc069129 100644 --- a/src/mesa/shader/slang/slang_compile_operation.c +++ b/src/mesa/shader/slang/slang_compile_operation.c @@ -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) } } - |