]> git.proxmox.com Git - mirror_qemu.git/commitdiff
ui/gtk: fix leaks found wtih fuzzing
authorDmitry Frolov <frolov@swemel.ru>
Fri, 25 Aug 2023 11:58:19 +0000 (14:58 +0300)
committerMarc-André Lureau <marcandre.lureau@redhat.com>
Mon, 4 Sep 2023 11:37:50 +0000 (15:37 +0400)
It is true, that there is no problem during runtime
from the first sight, because the memory is lost just
before qemu exits. Nevertheless, this change is necessary,
because AddressSanitizer is not able to recognize this
situation and produces crash-report (which is
false-positive in fact). Lots of False-Positive warnings
are davaluing problems, found with fuzzing, and thus the
whole methodology of dynamic analysis.
This patch eliminates such False-Positive reports,
and makes every problem, found with fuzzing, more valuable.

Fixes: 060ab76356 ("gtk: don't exit early in case gtk init fails")
Signed-off-by: Dmitry Frolov <frolov@swemel.ru>
Reviewed-by: Michael Tokarev <mjt@tls.msk.ru>
Message-Id: <20230825115818.1091936-1-frolov@swemel.ru>

ui/gtk.c

index c34c133550b461644583694a6901c3b2fc105e78..a14d56168de07c8e77ec8708f483c28a8d41ec72 100644 (file)
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -2359,7 +2359,7 @@ static void gtk_display_init(DisplayState *ds, DisplayOptions *opts)
 {
     VirtualConsole *vc;
 
-    GtkDisplayState *s = g_malloc0(sizeof(*s));
+    GtkDisplayState *s;
     GdkDisplay *window_display;
     GtkIconTheme *theme;
     char *dir;
@@ -2369,6 +2369,7 @@ static void gtk_display_init(DisplayState *ds, DisplayOptions *opts)
         exit(1);
     }
     assert(opts->type == DISPLAY_TYPE_GTK);
+    s = g_malloc0(sizeof(*s));
     s->opts = opts;
 
     theme = gtk_icon_theme_get_default();