From dc01cb9c5f38d6cdbb583ba70db5e51cc8901236 Mon Sep 17 00:00:00 2001 From: Andres Gomez Date: Wed, 22 Feb 2017 17:03:22 +0200 Subject: glsl: on UBO/SSBOs link error reset the number of active blocks to 0 While it's legal to have an active blocks count > 0 on link failure. Unless we actually assign memory for the blocks array we can end up segfaulting in calls such as glUniformBlockBinding(). To avoid having to NULL check these api calls we simply reset the block count to 0 if the array was not created. Signed-off-by: Andres Gomez Cc: Timothy Arceri Reviewed-by: Timothy Arceri (cherry picked from commit bf15b2b515d5f37fc67fea77dea9d2fbc1dc8bf1) --- src/compiler/glsl/linker.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/compiler/glsl/linker.cpp b/src/compiler/glsl/linker.cpp index d187b66ab53..9f1d6b70cb2 100644 --- a/src/compiler/glsl/linker.cpp +++ b/src/compiler/glsl/linker.cpp @@ -1176,6 +1176,12 @@ interstage_cross_validate_uniform_blocks(struct gl_shader_program *prog, for (unsigned k = 0; k <= i; k++) { delete[] InterfaceBlockStageIndex[k]; } + + /* Reset the block count. This will help avoid various segfaults + * from api calls that assume the array exists due to the count + * being non-zero. + */ + *num_blks = 0; return false; } -- cgit v1.2.3