aboutsummaryrefslogtreecommitdiff
path: root/ui/gtk-gl-area.c
diff options
context:
space:
mode:
authorPan Nengyuan <pannengyuan@huawei.com>2020-08-31 09:43:10 -0400
committerGerd Hoffmann <kraxel@redhat.com>2020-09-04 07:30:57 +0200
commit2cd1e3f91582efbee497a0069f6cbe19f324f0b3 (patch)
tree6f031c47f05bd558c7fdd0990e424ca4923e3bff /ui/gtk-gl-area.c
parent67a7bfe560a1bba59efab085cb3430f45176d382 (diff)
ui/gtk-gl-area: Plug memleak in gd_gl_area_create_context()
Receiving error in local variable err, and forgot to free it. This patch check the return value of 'gdk_window_create_gl_context' and 'gdk_gl_context_realize', then free err to fix it. Reported-by: Euler Robot <euler.robot@huawei.com> Signed-off-by: Pan Nengyuan <pannengyuan@huawei.com> Message-Id: <20200831134315.1221-6-pannengyuan@huawei.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Diffstat (limited to 'ui/gtk-gl-area.c')
-rw-r--r--ui/gtk-gl-area.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/ui/gtk-gl-area.c b/ui/gtk-gl-area.c
index 85f9d14c51..98c22d23f5 100644
--- a/ui/gtk-gl-area.c
+++ b/ui/gtk-gl-area.c
@@ -147,10 +147,21 @@ QEMUGLContext gd_gl_area_create_context(DisplayChangeListener *dcl,
gtk_gl_area_make_current(GTK_GL_AREA(vc->gfx.drawing_area));
window = gtk_widget_get_window(vc->gfx.drawing_area);
ctx = gdk_window_create_gl_context(window, &err);
+ if (err) {
+ g_printerr("Create gdk gl context failed: %s\n", err->message);
+ g_error_free(err);
+ return NULL;
+ }
gdk_gl_context_set_required_version(ctx,
params->major_ver,
params->minor_ver);
gdk_gl_context_realize(ctx, &err);
+ if (err) {
+ g_printerr("Realize gdk gl context failed: %s\n", err->message);
+ g_error_free(err);
+ g_clear_object(&ctx);
+ return NULL;
+ }
return ctx;
}