From 1cf838e66920d2fa9aeb10f7a1e3b8ac7f3ccbc5 Mon Sep 17 00:00:00 2001 From: Plamena Manolova Date: Fri, 26 Feb 2016 12:45:05 +0200 Subject: [PATCH] glsl: Account for EmptyUniformLocations being empty. Since EmptyUniformLocations is a list of empty spaces inside UniformRemapTable, it would end up being empty if there are no gaps. This would lead to find_empty_block producing a segmentation fault since foreach_list_typed doesn't work with empty lists. This patch accounts for this by checking whether EmptyUniformLocations is empty before iterating through it. --- src/compiler/glsl/link_uniforms.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/compiler/glsl/link_uniforms.cpp b/src/compiler/glsl/link_uniforms.cpp index deaba94..ac921d0 100644 --- a/src/compiler/glsl/link_uniforms.cpp +++ b/src/compiler/glsl/link_uniforms.cpp @@ -1048,6 +1048,9 @@ find_empty_block(struct gl_shader_program *prog, { const unsigned entries = MAX2(1, uniform->array_elements); + if (exec_list_is_empty(&prog->EmptyUniformLocations)) + return -1; + foreach_list_typed(struct empty_uniform_block, block, link, &prog->EmptyUniformLocations) { /* Found a block with enough slots to fit the uniform */ -- 2.4.3