[Mesa-dev] [PATCH 08/11] glsl: Check calloc return value in link_intrastage_shaders()

Juha-Pekka Heikkila juhapekka.heikkila at gmail.com
Thu Jun 19 05:24:25 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 | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp
index 247c828..1fc0213 100644
--- a/src/glsl/linker.cpp
+++ b/src/glsl/linker.cpp
@@ -1593,6 +1593,12 @@ link_intrastage_shaders(void *mem_ctx,
        */
       gl_shader **linking_shaders = (gl_shader **)
          calloc(num_shaders + 1, sizeof(gl_shader *));
+
+      if (linking_shaders == NULL) {
+         _mesa_error_no_memory(__func__);
+         ctx->Driver.DeleteShader(ctx, linked);
+         return NULL;
+      }
       memcpy(linking_shaders, shader_list, num_shaders * sizeof(gl_shader *));
       linking_shaders[num_shaders] = _mesa_glsl_get_builtin_function_shader();
 
-- 
1.8.1.2



More information about the mesa-dev mailing list