glsl/test: Fix use after free in test_optpass.
The variable state is free'd and afterwards state->error is used as the return value, resulting in a use after free bug detected by memory safety tools like address sanitizer. Signed-off-by: Hanno Böck <hanno@hboeck.de> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=108636 Reviewed-by: Eric Engestrom <eric.engestrom@intel.com> Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
This commit is contained in:
@@ -166,6 +166,7 @@ int test_optpass(int argc, char **argv)
|
|||||||
int loop = 0;
|
int loop = 0;
|
||||||
int shader_type = GL_VERTEX_SHADER;
|
int shader_type = GL_VERTEX_SHADER;
|
||||||
int quiet = 0;
|
int quiet = 0;
|
||||||
|
int error;
|
||||||
|
|
||||||
const struct option optpass_opts[] = {
|
const struct option optpass_opts[] = {
|
||||||
{ "input-ir", no_argument, &input_format_ir, 1 },
|
{ "input-ir", no_argument, &input_format_ir, 1 },
|
||||||
@@ -264,9 +265,11 @@ int test_optpass(int argc, char **argv)
|
|||||||
printf("--\n");
|
printf("--\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
error = state->error;
|
||||||
|
|
||||||
ralloc_free(state);
|
ralloc_free(state);
|
||||||
ralloc_free(shader);
|
ralloc_free(shader);
|
||||||
|
|
||||||
return state->error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user