[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 09/12] ui/shader: fix potential leak of shader on error
From: |
marcandre . lureau |
Subject: |
[PATCH v2 09/12] ui/shader: fix potential leak of shader on error |
Date: |
Thu, 17 Feb 2022 15:58:26 +0400 |
From: Marc-André Lureau <marcandre.lureau@redhat.com>
Value of 0 for program and shaders are silently ignored and indicate error.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
ui/shader.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/ui/shader.c b/ui/shader.c
index e8b8d321b7c7..4c80fc831f68 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);
--
2.34.1.428.gdcc0cd074f0c
- [PATCH v2 00/12] GL & D-Bus display related fixes, marcandre . lureau, 2022/02/17
- [PATCH v2 01/12] ui/console: fix crash when using gl context with non-gl listeners, marcandre . lureau, 2022/02/17
- [PATCH v2 02/12] ui/console: fix texture leak when calling surface_gl_create_texture(), marcandre . lureau, 2022/02/17
- [PATCH v2 03/12] ui: do not create a surface when resizing a GL scanout, marcandre . lureau, 2022/02/17
- [PATCH v2 04/12] ui/console: move check for compatible GL context, marcandre . lureau, 2022/02/17
- [PATCH v2 05/12] ui/console: move dcl compatiblity check to a callback, marcandre . lureau, 2022/02/17
- [PATCH v2 06/12] ui/console: egl-headless is compatible with non-gl listeners, marcandre . lureau, 2022/02/17
- [PATCH v2 07/12] ui/dbus: associate the DBusDisplayConsole listener with the given console, marcandre . lureau, 2022/02/17
- [PATCH v2 08/12] ui/console: move console compatibility check to dcl_display_console(), marcandre . lureau, 2022/02/17
- [PATCH v2 09/12] ui/shader: fix potential leak of shader on error,
marcandre . lureau <=
- [PATCH v2 10/12] ui/shader: free associated programs, marcandre . lureau, 2022/02/17
- [PATCH v2 11/12] ui/console: add a dpy_gfx_switch callback helper, marcandre . lureau, 2022/02/17
- [PATCH v2 12/12] ui/dbus: fix texture sharing, marcandre . lureau, 2022/02/17
- Re: [PATCH v2 00/12] GL & D-Bus display related fixes, Akihiko Odaki, 2022/02/17