[Mesa-dev] [PATCH 4/9] glsl: Check calloc return value in link_intrastage_shaders()
Juha-Pekka Heikkila
juhapekka.heikkila at gmail.com
Thu Jul 3 01:13:14 PDT 2014
Check calloc return value while adding build-in functions.
Signed-off-by: Juha-Pekka Heikkila <juhapekka.heikkila at gmail.com>
---
src/glsl/linker.cpp | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp
index d588bc6..2f004f1 100644
--- a/src/glsl/linker.cpp
+++ b/src/glsl/linker.cpp
@@ -1705,12 +1705,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);
}
--
1.8.1.2
More information about the mesa-dev
mailing list