aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorYevhenii Kolesnikov <[email protected]>2019-07-10 13:44:44 +0300
committerYevhenii Kolesnikov <[email protected]>2019-07-12 11:07:08 +0300
commit8c5692b696ed4a8d59da83cdcfef9548b7e6b4e7 (patch)
treec1c3f851ad5912ee21b0ff40f576c9101fe1b72b /src
parent712ac8303348113ec1596f279057555e5e34ef1f (diff)
glsl/link_varyings: Fix hash table leak
Hash tables were not destroyed at return. v2: Use ralloc_context (Eric Anholt) Signed-off-by: Yevhenii Kolesnikov <[email protected]> Acked-by: Lionel Landwerlin <[email protected]> Reviewed-by: Eric Anholt <[email protected]> Reviewed-by: Lionel Landwerlin <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/compiler/glsl/link_varyings.cpp17
1 files changed, 8 insertions, 9 deletions
diff --git a/src/compiler/glsl/link_varyings.cpp b/src/compiler/glsl/link_varyings.cpp
index 1263d6cbdb1..c7774a2531b 100644
--- a/src/compiler/glsl/link_varyings.cpp
+++ b/src/compiler/glsl/link_varyings.cpp
@@ -2581,14 +2581,15 @@ assign_varying_locations(struct gl_context *ctx,
ctx->Extensions.ARB_enhanced_layouts,
producer ? producer->Stage : MESA_SHADER_NONE,
consumer ? consumer->Stage : MESA_SHADER_NONE);
+ void *hash_table_ctx = ralloc_context(NULL);
hash_table *tfeedback_candidates =
- _mesa_hash_table_create(NULL, _mesa_key_hash_string,
+ _mesa_hash_table_create(hash_table_ctx, _mesa_key_hash_string,
_mesa_key_string_equal);
hash_table *consumer_inputs =
- _mesa_hash_table_create(NULL, _mesa_key_hash_string,
+ _mesa_hash_table_create(hash_table_ctx, _mesa_key_hash_string,
_mesa_key_string_equal);
hash_table *consumer_interface_inputs =
- _mesa_hash_table_create(NULL, _mesa_key_hash_string,
+ _mesa_hash_table_create(hash_table_ctx, _mesa_key_hash_string,
_mesa_key_string_equal);
ir_variable *consumer_inputs_with_locations[VARYING_SLOT_TESS_MAX] = {
NULL,
@@ -2684,6 +2685,7 @@ assign_varying_locations(struct gl_context *ctx,
linker_error(prog, "output %s is assigned to stream=%d but "
"is linked to an input, which requires stream=0",
output_var->name, output_var->data.stream);
+ ralloc_free(hash_table_ctx);
return false;
}
}
@@ -2710,7 +2712,7 @@ assign_varying_locations(struct gl_context *ctx,
= tfeedback_decls[i].find_candidate(prog, tfeedback_candidates);
if (matched_candidate == NULL) {
- _mesa_hash_table_destroy(tfeedback_candidates, NULL);
+ ralloc_free(hash_table_ctx);
return false;
}
@@ -2739,9 +2741,6 @@ assign_varying_locations(struct gl_context *ctx,
}
}
- _mesa_hash_table_destroy(consumer_inputs, NULL);
- _mesa_hash_table_destroy(consumer_interface_inputs, NULL);
-
uint8_t components[MAX_VARYINGS_INCL_PATCH] = {0};
const unsigned slots_used = matches.assign_locations(
prog, components, reserved_slots);
@@ -2750,12 +2749,12 @@ assign_varying_locations(struct gl_context *ctx,
for (unsigned i = 0; i < num_tfeedback_decls; ++i) {
if (tfeedback_decls[i].is_varying()) {
if (!tfeedback_decls[i].assign_location(ctx, prog)) {
- _mesa_hash_table_destroy(tfeedback_candidates, NULL);
+ ralloc_free(hash_table_ctx);
return false;
}
}
}
- _mesa_hash_table_destroy(tfeedback_candidates, NULL);
+ ralloc_free(hash_table_ctx);
if (consumer && producer) {
foreach_in_list(ir_instruction, node, consumer->ir) {