diff mbox series

fix leaks found wtih fuzzing

Message ID 20230825092907.862583-1-frolov@swemel.ru (mailing list archive)
State New, archived
Headers show
Series fix leaks found wtih fuzzing | expand

Commit Message

Dmitry Frolov Aug. 25, 2023, 9:29 a.m. UTC
It is true, that there is no problem during runtime
from the first sight, because the memmory 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>
---
v2: Moved declarations in the beginning.

 ui/gtk.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Alexey Khoroshilov Aug. 25, 2023, 9:48 a.m. UTC | #1
On 25.08.2023 12:29, Dmitry Frolov wrote:
> It is true, that there is no problem during runtime
> from the first sight, because the memmory 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.

It would be good to separe answer to the previous mail and commit message.

> 
> Fixes: 060ab76356 ("gtk: don't exit early in case gtk init fails")
> 
> Signed-off-by: Dmitry Frolov <frolov@swemel.ru>
> ---
> v2: Moved declarations in the beginning.
> 
>  ui/gtk.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/ui/gtk.c b/ui/gtk.c
> index 8ba41c8f13..23a78787df 100644
> --- a/ui/gtk.c
> +++ b/ui/gtk.c
> @@ -2360,7 +2360,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;
> @@ -2372,6 +2372,7 @@ static void gtk_display_init(DisplayState *ds, DisplayOptions *opts)
>      assert(opts->type == DISPLAY_TYPE_GTK);>      s->opts = opts;
's' is already used here.

>  
> +    *s = g_malloc0(sizeof(*s));
s = g_malloc0(sizeof(*s));

>      theme = gtk_icon_theme_get_default();
>      dir = get_relocated_path(CONFIG_QEMU_ICONDIR);
>      gtk_icon_theme_prepend_search_path(theme, dir);


Otherwise, I belive the change makes sense.

--
Alexey Khoroshilov
Linux Verification Center, ISPRAS
diff mbox series

Patch

diff --git a/ui/gtk.c b/ui/gtk.c
index 8ba41c8f13..23a78787df 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -2360,7 +2360,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;
@@ -2372,6 +2372,7 @@  static void gtk_display_init(DisplayState *ds, DisplayOptions *opts)
     assert(opts->type == DISPLAY_TYPE_GTK);
     s->opts = opts;
 
+    *s = g_malloc0(sizeof(*s));
     theme = gtk_icon_theme_get_default();
     dir = get_relocated_path(CONFIG_QEMU_ICONDIR);
     gtk_icon_theme_prepend_search_path(theme, dir);