diff options
author | Marc-André Lureau <marcandre.lureau@redhat.com> | 2022-02-17 11:36:45 +0400 |
---|---|---|
committer | Marc-André Lureau <marcandre.lureau@redhat.com> | 2022-03-14 15:16:14 +0400 |
commit | 8fe496adacc03fe37fba6765d34618a390fabdc8 (patch) | |
tree | f3b25ee56ce118819f55365f12ee2f138902dd7f /ui | |
parent | 4b7b661d8feccb8d12289bce7814e89ef827ecce (diff) | |
download | qemu-8fe496adacc03fe37fba6765d34618a390fabdc8.zip qemu-8fe496adacc03fe37fba6765d34618a390fabdc8.tar.gz qemu-8fe496adacc03fe37fba6765d34618a390fabdc8.tar.bz2 |
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>
Diffstat (limited to 'ui')
-rw-r--r-- | ui/shader.c | 6 |
1 files changed, 4 insertions, 2 deletions
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_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); |