ui/shader: fix potential leak of shader on error
Value of 0 for program and shaders are silently ignored and indicate error.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
diff --git a/ui/shader.c b/ui/shader.c
index e8b8d32..4c80fc8 100644
--- a/ui/shader.c
+++ b/ui/shader.c
@@ -130,15 +130,17 @@
static GLuint qemu_gl_create_compile_link_program(const GLchar *vert_src,
const GLchar *frag_src)
{
- GLuint vert_shader, frag_shader, program;
+ GLuint vert_shader, frag_shader, program = 0;
vert_shader = qemu_gl_create_compile_shader(GL_VERTEX_SHADER, vert_src);
frag_shader = qemu_gl_create_compile_shader(GL_FRAGMENT_SHADER, frag_src);
if (!vert_shader || !frag_shader) {
- return 0;
+ goto end;
}
program = qemu_gl_create_link_program(vert_shader, frag_shader);
+
+end:
glDeleteShader(vert_shader);
glDeleteShader(frag_shader);