[Mesa-dev] [PATCH 1/2] i965: in brw_link_shader() react to low memory

Juha-Pekka Heikkila juhapekka.heikkila at gmail.com
Wed Feb 3 08:56:51 UTC 2016


Check _mesa_new_parameter_list() returned other than null.

Signed-off-by: Juha-Pekka Heikkila <juhapekka.heikkila at gmail.com>
---
 src/mesa/drivers/dri/i965/brw_link.cpp | 4 ++++
 src/mesa/main/ff_fragment_shader.cpp   | 6 ++++--
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_link.cpp b/src/mesa/drivers/dri/i965/brw_link.cpp
index db4ba88..5411fb8 100644
--- a/src/mesa/drivers/dri/i965/brw_link.cpp
+++ b/src/mesa/drivers/dri/i965/brw_link.cpp
@@ -221,6 +221,10 @@ brw_link_shader(struct gl_context *ctx, struct gl_shader_program *shProg)
       if (!prog)
 	return false;
       prog->Parameters = _mesa_new_parameter_list();
+      if (!prog->Parameters) {
+         _mesa_error(ctx, GL_OUT_OF_MEMORY, "brw_link_shader");
+         return false;
+      }
 
       _mesa_copy_linked_program_data((gl_shader_stage) stage, shProg, prog);
 
diff --git a/src/mesa/main/ff_fragment_shader.cpp b/src/mesa/main/ff_fragment_shader.cpp
index b0ce8c4..611deff 100644
--- a/src/mesa/main/ff_fragment_shader.cpp
+++ b/src/mesa/main/ff_fragment_shader.cpp
@@ -1264,9 +1264,11 @@ create_new_program(struct gl_context *ctx, struct state_key *key)
 
    _mesa_glsl_link_shader(ctx, p.shader_program);
 
-   if (!p.shader_program->LinkStatus)
+   if (!p.shader_program->LinkStatus) {
       _mesa_problem(ctx, "Failed to link fixed function fragment shader: %s\n",
-		    p.shader_program->InfoLog);
+                    (p.shader_program->InfoLog)?p.shader_program->InfoLog:
+                                                "Out of Memory");
+   }
 
    ralloc_free(p.mem_ctx);
    return p.shader_program;
-- 
1.9.1



More information about the mesa-dev mailing list