qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Gerd Hoffmann <kraxel@redhat.com>
To: qemu-devel@nongnu.org
Cc: Pan Nengyuan <pannengyuan@huawei.com>,
	Gerd Hoffmann <kraxel@redhat.com>,
	Euler Robot <euler.robot@huawei.com>
Subject: [PULL 1/5] ui/gtk-gl-area: Plug memleak in gd_gl_area_create_context()
Date: Mon, 31 Aug 2020 13:04:12 +0200	[thread overview]
Message-ID: <20200831110416.15176-2-kraxel@redhat.com> (raw)
In-Reply-To: <20200831110416.15176-1-kraxel@redhat.com>

From: Pan Nengyuan <pannengyuan@huawei.com>

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>
---
 ui/gtk-gl-area.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/ui/gtk-gl-area.c b/ui/gtk-gl-area.c
index 85f9d14c51f1..98c22d23f501 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;
 }
 
-- 
2.27.0



  reply	other threads:[~2020-08-31 11:07 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-31 11:04 [PULL 0/5] Ui 20200831 patches Gerd Hoffmann
2020-08-31 11:04 ` Gerd Hoffmann [this message]
2020-08-31 11:04 ` [PULL 2/5] vnc-auth-sasl: Plug memleak in vnc_socket_ip_addr_string Gerd Hoffmann
2020-08-31 11:04 ` [PULL 3/5] meson: fix keymaps witout qemu-keymap Gerd Hoffmann
2020-08-31 11:04 ` [PULL 4/5] ui: Add more mouse buttons to SPICE Gerd Hoffmann
2020-08-31 11:04 ` [PULL 5/5] ui/gtk: Update refresh interval after widget is realized Gerd Hoffmann
2020-09-01  9:52 ` [PULL 0/5] Ui 20200831 patches Peter Maydell
2020-09-01 14:16   ` Gerd Hoffmann
2020-09-01 14:54     ` Peter Maydell
2020-09-02  9:42       ` Gerd Hoffmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200831110416.15176-2-kraxel@redhat.com \
    --to=kraxel@redhat.com \
    --cc=euler.robot@huawei.com \
    --cc=pannengyuan@huawei.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).