diff options
author | Juha-Pekka Heikkila <[email protected]> | 2014-05-07 16:20:12 +0300 |
---|---|---|
committer | Tapani Pälli <[email protected]> | 2014-09-23 10:25:02 +0300 |
commit | d2f0442bf632eef7dddcd77add8556f6be029b5e (patch) | |
tree | c20e7ec8e44963d201b7380b75a08dc5fdf8f2b9 | |
parent | 808b8e59c09ac5977ab020bd1771225a4e0a4cc4 (diff) |
glsl: Check calloc return value in link_intrastage_shaders()
Check calloc return value while adding build-in functions.
Signed-off-by: Juha-Pekka Heikkila <[email protected]>
Reviewed-by: Anuj Phogat <[email protected]>
-rw-r--r-- | src/glsl/linker.cpp | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp index 7689198b066..75e8b1696c5 100644 --- a/src/glsl/linker.cpp +++ b/src/glsl/linker.cpp @@ -1714,12 +1714,19 @@ link_intrastage_shaders(void *mem_ctx, */ gl_shader **linking_shaders = (gl_shader **) calloc(num_shaders + 1, sizeof(gl_shader *)); - memcpy(linking_shaders, shader_list, num_shaders * sizeof(gl_shader *)); - linking_shaders[num_shaders] = _mesa_glsl_get_builtin_function_shader(); - ok = link_function_calls(prog, linked, linking_shaders, num_shaders + 1); + ok = linking_shaders != NULL; - free(linking_shaders); + if (ok) { + memcpy(linking_shaders, shader_list, num_shaders * sizeof(gl_shader *)); + linking_shaders[num_shaders] = _mesa_glsl_get_builtin_function_shader(); + + ok = link_function_calls(prog, linked, linking_shaders, num_shaders + 1); + + free(linking_shaders); + } else { + _mesa_error_no_memory(__func__); + } } else { ok = link_function_calls(prog, linked, shader_list, num_shaders); } |