summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@redhat.com>2016-03-18 23:18:17 +0100
committerDave Airlie <airlied@redhat.com>2016-03-31 09:59:17 +1000
commit7b2fbc9fd3ef64c62b21569aebeaf4dd7769bab4 (patch)
treea4571e53af3f4fbf01afea7b09eb37cfb34e6520
parent117b54befbb960334d072f991b8b947550054eae (diff)
shader: avoid use after free
If the shader failed to be finished, it should be removed from the hashtable if it was already inserted. Use the goto error path in this case to handle shader destroy and prevent potential later lookup of invalid shader from the hashtable. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com>
-rw-r--r--src/vrend_renderer.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/vrend_renderer.c b/src/vrend_renderer.c
index 77c79f2..cc0f8b8 100644
--- a/src/vrend_renderer.c
+++ b/src/vrend_renderer.c
@@ -2145,7 +2145,6 @@ static int vrend_finish_shader(struct vrend_context *ctx,
r = vrend_shader_select(ctx, sel, NULL);
if (r) {
- vrend_destroy_shader_selector(sel);
return EINVAL;
}
return 0;
@@ -2245,9 +2244,11 @@ int vrend_create_shader(struct vrend_context *ctx,
goto error;
}
- if (vrend_finish_shader(ctx, sel, tokens))
- new_shader = false;
- else {
+ if (vrend_finish_shader(ctx, sel, tokens)) {
+ free(tokens);
+ ret = EINVAL;
+ goto error;
+ } else {
free(sel->tmp_buf);
sel->tmp_buf = NULL;
}