[mutter] xprops: Use g_new0 instead of calloc in meta_prop_get_motif_hints()



commit 5e6d98e79f557468767b0928775b237ebbd506c7
Author: Hans de Goede <hdegoede redhat com>
Date:   Mon Sep 9 09:18:45 2019 +0200

    xprops: Use g_new0 instead of calloc in meta_prop_get_motif_hints()
    
    Use g_new0 instead of calloc for motif_hints_from_results and adjust
    its callers to use g_free.
    
    Note that in the process_request_frame_extents function this replaces
    the wrong original mismatch of calloc + XFree with a matching g_malloc +
    g_free pair.
    
    https://gitlab.gnome.org/GNOME/mutter/merge_requests/786

 src/x11/events.c |  2 +-
 src/x11/xprops.c | 11 ++---------
 2 files changed, 3 insertions(+), 10 deletions(-)
---
diff --git a/src/x11/events.c b/src/x11/events.c
index 742e291f1..7fc7e3bf9 100644
--- a/src/x11/events.c
+++ b/src/x11/events.c
@@ -989,7 +989,7 @@ process_request_frame_extents (MetaX11Display *x11_display,
                    32, PropModeReplace, (guchar*) data, 4);
   meta_x11_error_trap_pop (x11_display);
 
-  meta_XFree (hints);
+  g_free (hints);
 }
 
 /* from fvwm2, Copyright Matthias Clasen, Dominik Vogt */
diff --git a/src/x11/xprops.c b/src/x11/xprops.c
index 397019c70..10e56b60d 100644
--- a/src/x11/xprops.c
+++ b/src/x11/xprops.c
@@ -313,14 +313,7 @@ motif_hints_from_results (GetPropertyResults *results,
    * MotifWmHints than the one we expect, apparently.  I'm not sure of
    * the history behind it. See bug #89841 for example.
    */
-  *hints_p = calloc (1, sizeof (MotifWmHints));
-  if (*hints_p == NULL)
-    {
-      g_free (results->prop);
-      results->prop = NULL;
-      return FALSE;
-    }
-
+  *hints_p = g_new0 (MotifWmHints, 1);
   memcpy(*hints_p, results->prop, MIN (sizeof (MotifWmHints),
                                        results->n_items * sizeof (uint32_t)));
 
@@ -1085,7 +1078,7 @@ free_value (MetaPropValue *value)
       g_free (value->v.str);
       break;
     case META_PROP_VALUE_MOTIF_HINTS:
-      free (value->v.motif_hints);
+      g_free (value->v.motif_hints);
       break;
     case META_PROP_VALUE_CARDINAL:
       break;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]