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>
This commit is contained in:
Marc-André Lureau 2022-02-17 11:36:45 +04:00
parent 4b7b661d8f
commit 8fe496adac

View File

@ -130,15 +130,17 @@ static GLuint qemu_gl_create_link_program(GLuint vert, GLuint frag)
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);