Blame SOURCES/0014-Prefer-using-g_malloc0-g_free.patch

dfc2f2
From d9b9e94cce65f1af0f2bb263394d1c7f63683ebd Mon Sep 17 00:00:00 2001
dfc2f2
From: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= <fidencio@redhat.com>
dfc2f2
Date: Fri, 11 Jul 2014 17:13:09 +0200
dfc2f2
Subject: [PATCH] Prefer using g_malloc0()/g_free()
dfc2f2
dfc2f2
As we already depend on GLib, let's use g_{malloc,new}0() instead of the
dfc2f2
standard malloc() or the spice_{malloc,new}*() and g_free() instead of
dfc2f2
the standard free() when possible.
dfc2f2
Memory allocated by other libraries using malloc() should still be freed
dfc2f2
by free().
dfc2f2
As a side effect of the changes, we are muting a few warnings caught by
dfc2f2
coverity.
dfc2f2
---
dfc2f2
 gtk/channel-cursor.c          |  2 +-
dfc2f2
 gtk/channel-display-mjpeg.c   |  8 +++-----
dfc2f2
 gtk/channel-display.c         |  8 ++++----
dfc2f2
 gtk/channel-main.c            | 12 ++++++------
dfc2f2
 gtk/channel-record.c          |  2 +-
dfc2f2
 gtk/controller/test.c         |  4 ++--
dfc2f2
 gtk/decode-glz.c              | 10 +++++-----
dfc2f2
 gtk/decode-jpeg.c             |  2 +-
dfc2f2
 gtk/decode-zlib.c             |  2 +-
dfc2f2
 gtk/spice-channel.c           | 20 ++++++++++----------
dfc2f2
 gtk/spice-client-gtk.override |  7 ++++---
dfc2f2
 gtk/spice-session.c           |  2 +-
dfc2f2
 gtk/spice-widget.c            |  2 +-
dfc2f2
 gtk/usb-device-manager.c      |  2 +-
dfc2f2
 14 files changed, 41 insertions(+), 42 deletions(-)
dfc2f2
dfc2f2
diff --git a/gtk/channel-cursor.c b/gtk/channel-cursor.c
dfc2f2
index 36c0ca4..3f49641 100644
dfc2f2
--- a/gtk/channel-cursor.c
dfc2f2
+++ b/gtk/channel-cursor.c
dfc2f2
@@ -367,7 +367,7 @@ static display_cursor *set_cursor(SpiceChannel *channel, SpiceCursor *scursor)
dfc2f2
     g_return_val_if_fail(scursor->data_size != 0, NULL);
dfc2f2
 
dfc2f2
     size = 4 * hdr->width * hdr->height;
dfc2f2
-    cursor = spice_malloc(sizeof(*cursor) + size);
dfc2f2
+    cursor = g_malloc0(sizeof(*cursor) + size);
dfc2f2
     cursor->hdr = *hdr;
dfc2f2
     cursor->default_cursor = FALSE;
dfc2f2
     cursor->refcount = 1;
dfc2f2
diff --git a/gtk/channel-display-mjpeg.c b/gtk/channel-display-mjpeg.c
dfc2f2
index 627aab4..7d9beea 100644
dfc2f2
--- a/gtk/channel-display-mjpeg.c
dfc2f2
+++ b/gtk/channel-display-mjpeg.c
dfc2f2
@@ -71,11 +71,9 @@ void stream_mjpeg_data(display_stream *st)
dfc2f2
     uint8_t *lines[4];
dfc2f2
 
dfc2f2
     stream_get_dimensions(st, &width, &height);
dfc2f2
-    dest = malloc(width * height * 4);
dfc2f2
+    dest = g_malloc0(width * height * 4);
dfc2f2
 
dfc2f2
-    if (st->out_frame) {
dfc2f2
-        free(st->out_frame);
dfc2f2
-    }
dfc2f2
+    g_free(st->out_frame);
dfc2f2
     st->out_frame = dest;
dfc2f2
 
dfc2f2
     jpeg_read_header(&st->mjpeg_cinfo, 1);
dfc2f2
@@ -151,6 +149,6 @@ G_GNUC_INTERNAL
dfc2f2
 void stream_mjpeg_cleanup(display_stream *st)
dfc2f2
 {
dfc2f2
     jpeg_destroy_decompress(&st->mjpeg_cinfo);
dfc2f2
-    free(st->out_frame);
dfc2f2
+    g_free(st->out_frame);
dfc2f2
     st->out_frame = NULL;
dfc2f2
 }
dfc2f2
diff --git a/gtk/channel-display.c b/gtk/channel-display.c
dfc2f2
index 80df0f3..9170bf4 100644
dfc2f2
--- a/gtk/channel-display.c
dfc2f2
+++ b/gtk/channel-display.c
dfc2f2
@@ -783,7 +783,7 @@ static void destroy_canvas(display_surface *surface)
dfc2f2
     jpeg_decoder_destroy(surface->jpeg_decoder);
dfc2f2
 
dfc2f2
     if (surface->shmid == -1) {
dfc2f2
-        free(surface->data);
dfc2f2
+        g_free(surface->data);
dfc2f2
     }
dfc2f2
 #ifdef HAVE_SYS_SHM_H
dfc2f2
     else {
dfc2f2
@@ -1039,7 +1039,7 @@ static void display_handle_stream_create(SpiceChannel *channel, SpiceMsgIn *in)
dfc2f2
         memset(c->streams + n, 0, (c->nstreams - n) * sizeof(c->streams[0]));
dfc2f2
     }
dfc2f2
     g_return_if_fail(c->streams[op->id] == NULL);
dfc2f2
-    c->streams[op->id] = spice_new0(display_stream, 1);
dfc2f2
+    c->streams[op->id] = g_new0(display_stream, 1);
dfc2f2
     st = c->streams[op->id];
dfc2f2
 
dfc2f2
     st->msg_create = in;
dfc2f2
@@ -1539,7 +1539,7 @@ static void destroy_stream(SpiceChannel *channel, int id)
dfc2f2
     g_queue_free(st->msgq);
dfc2f2
     if (st->timeout != 0)
dfc2f2
         g_source_remove(st->timeout);
dfc2f2
-    free(st);
dfc2f2
+    g_free(st);
dfc2f2
     c->streams[id] = NULL;
dfc2f2
 }
dfc2f2
 
dfc2f2
@@ -1551,7 +1551,7 @@ static void clear_streams(SpiceChannel *channel)
dfc2f2
     for (i = 0; i < c->nstreams; i++) {
dfc2f2
         destroy_stream(channel, i);
dfc2f2
     }
dfc2f2
-    free(c->streams);
dfc2f2
+    g_free(c->streams);
dfc2f2
     c->streams = NULL;
dfc2f2
     c->nstreams = 0;
dfc2f2
 }
dfc2f2
diff --git a/gtk/channel-main.c b/gtk/channel-main.c
dfc2f2
index 43d8e6d..84e6142 100644
dfc2f2
--- a/gtk/channel-main.c
dfc2f2
+++ b/gtk/channel-main.c
dfc2f2
@@ -1150,7 +1150,7 @@ gboolean spice_main_send_monitor_config(SpiceMainChannel *channel)
dfc2f2
     }
dfc2f2
 
dfc2f2
     size = sizeof(VDAgentMonitorsConfig) + sizeof(VDAgentMonConfig) * monitors;
dfc2f2
-    mon = spice_malloc0(size);
dfc2f2
+    mon = g_malloc0(size);
dfc2f2
 
dfc2f2
     mon->num_of_monitors = monitors;
dfc2f2
     if (c->disable_display_position == FALSE ||
dfc2f2
@@ -1181,7 +1181,7 @@ gboolean spice_main_send_monitor_config(SpiceMainChannel *channel)
dfc2f2
         monitors_align(mon->monitors, mon->num_of_monitors);
dfc2f2
 
dfc2f2
     agent_msg_queue(channel, VD_AGENT_MONITORS_CONFIG, size, mon);
dfc2f2
-    free(mon);
dfc2f2
+    g_free(mon);
dfc2f2
 
dfc2f2
     spice_channel_wakeup(SPICE_CHANNEL(channel), FALSE);
dfc2f2
     if (c->timer_id != 0) {
dfc2f2
@@ -1233,7 +1233,7 @@ static void agent_announce_caps(SpiceMainChannel *channel)
dfc2f2
         return;
dfc2f2
 
dfc2f2
     size = sizeof(VDAgentAnnounceCapabilities) + VD_AGENT_CAPS_BYTES;
dfc2f2
-    caps = spice_malloc0(size);
dfc2f2
+    caps = g_malloc0(size);
dfc2f2
     if (!c->agent_caps_received)
dfc2f2
         caps->request = 1;
dfc2f2
     VD_AGENT_SET_CAPABILITY(caps->caps, VD_AGENT_CAP_MOUSE_STATE);
dfc2f2
@@ -1244,7 +1244,7 @@ static void agent_announce_caps(SpiceMainChannel *channel)
dfc2f2
     VD_AGENT_SET_CAPABILITY(caps->caps, VD_AGENT_CAP_CLIPBOARD_SELECTION);
dfc2f2
 
dfc2f2
     agent_msg_queue(channel, VD_AGENT_ANNOUNCE_CAPABILITIES, size, caps);
dfc2f2
-    free(caps);
dfc2f2
+    g_free(caps);
dfc2f2
 }
dfc2f2
 
dfc2f2
 /* any context: the message is not flushed immediately,
dfc2f2
@@ -1978,7 +1978,7 @@ static void main_handle_agent_data_msg(SpiceChannel* channel, int* msg_size, guc
dfc2f2
             SPICE_DEBUG("agent msg start: msg_size=%d, protocol=%d, type=%d",
dfc2f2
                         c->agent_msg.size, c->agent_msg.protocol, c->agent_msg.type);
dfc2f2
             g_return_if_fail(c->agent_msg_data == NULL);
dfc2f2
-            c->agent_msg_data = g_malloc(c->agent_msg.size);
dfc2f2
+            c->agent_msg_data = g_malloc0(c->agent_msg.size);
dfc2f2
         }
dfc2f2
     }
dfc2f2
 
dfc2f2
@@ -2839,7 +2839,7 @@ static void file_xfer_send_start_msg_async(SpiceMainChannel *channel,
dfc2f2
     SpiceFileXferTask *task;
dfc2f2
     static uint32_t xfer_id;    /* Used to identify task id */
dfc2f2
 
dfc2f2
-    task = spice_malloc0(sizeof(SpiceFileXferTask));
dfc2f2
+    task = g_malloc0(sizeof(SpiceFileXferTask));
dfc2f2
     task->id = ++xfer_id;
dfc2f2
     task->channel = g_object_ref(channel);
dfc2f2
     task->file = g_object_ref(file);
dfc2f2
diff --git a/gtk/channel-record.c b/gtk/channel-record.c
dfc2f2
index e1f3ec7..32b8faa 100644
dfc2f2
--- a/gtk/channel-record.c
dfc2f2
+++ b/gtk/channel-record.c
dfc2f2
@@ -449,7 +449,7 @@ static void record_handle_start(SpiceChannel *channel, SpiceMsgIn *in)
dfc2f2
     c->frame_bytes = FRAME_SIZE * 16 * start->channels / 8;
dfc2f2
 
dfc2f2
     g_free(c->last_frame);
dfc2f2
-    c->last_frame = g_malloc(c->frame_bytes);
dfc2f2
+    c->last_frame = g_malloc0(c->frame_bytes);
dfc2f2
     c->last_frame_current = 0;
dfc2f2
 
dfc2f2
     switch (c->mode) {
dfc2f2
diff --git a/gtk/controller/test.c b/gtk/controller/test.c
dfc2f2
index 289ffb8..5093aa3 100644
dfc2f2
--- a/gtk/controller/test.c
dfc2f2
+++ b/gtk/controller/test.c
dfc2f2
@@ -94,13 +94,13 @@ void send_value (uint32_t id, uint32_t value)
dfc2f2
 void send_data (uint32_t id, uint8_t* data, size_t data_size)
dfc2f2
 {
dfc2f2
     size_t size = sizeof (ControllerData) + data_size;
dfc2f2
-    ControllerData* msg = (ControllerData*)malloc (size);
dfc2f2
+    ControllerData* msg = (ControllerData*)g_malloc0 (size);
dfc2f2
 
dfc2f2
     msg->base.id = id;
dfc2f2
     msg->base.size = (uint32_t)size;
dfc2f2
     memcpy (msg->data, data, data_size);
dfc2f2
     write_to_pipe (msg, size);
dfc2f2
-    free (msg);
dfc2f2
+    g_free (msg);
dfc2f2
 }
dfc2f2
 
dfc2f2
 ssize_t read_from_pipe (void* data, size_t size)
dfc2f2
diff --git a/gtk/decode-glz.c b/gtk/decode-glz.c
dfc2f2
index e2626ef..5287389 100644
dfc2f2
--- a/gtk/decode-glz.c
dfc2f2
+++ b/gtk/decode-glz.c
dfc2f2
@@ -50,7 +50,7 @@ static struct glz_image *glz_image_new(struct glz_image_hdr *hdr,
dfc2f2
 
dfc2f2
     g_return_val_if_fail(type == LZ_IMAGE_TYPE_RGB32 || type == LZ_IMAGE_TYPE_RGBA, NULL);
dfc2f2
 
dfc2f2
-    img = spice_new0(struct glz_image, 1);
dfc2f2
+    img = g_new0(struct glz_image, 1);
dfc2f2
     img->hdr = *hdr;
dfc2f2
     img->surface = alloc_lz_image_surface
dfc2f2
         (opaque, type == LZ_IMAGE_TYPE_RGBA ? PIXMAN_a8r8g8b8 : PIXMAN_x8r8g8b8,
dfc2f2
@@ -92,7 +92,7 @@ static void glz_decoder_window_resize(SpiceGlzDecoderWindow *w)
dfc2f2
 
dfc2f2
     SPICE_DEBUG("%s: array resize %d -> %d", __FUNCTION__,
dfc2f2
                 w->nimages, w->nimages * 2);
dfc2f2
-    new_images = spice_new0(struct glz_image*, w->nimages * 2);
dfc2f2
+    new_images = g_new0(struct glz_image*, w->nimages * 2);
dfc2f2
     for (i = 0; i < w->nimages; i++) {
dfc2f2
         if (w->images[i] == NULL) {
dfc2f2
             /*
dfc2f2
@@ -438,13 +438,13 @@ void glz_decoder_window_clear(SpiceGlzDecoderWindow *w)
dfc2f2
 
dfc2f2
     w->nimages = 16;
dfc2f2
     g_free(w->images);
dfc2f2
-    w->images = spice_new0(struct glz_image*, w->nimages);
dfc2f2
+    w->images = g_new0(struct glz_image*, w->nimages);
dfc2f2
     w->tail_gap = 0;
dfc2f2
 }
dfc2f2
 
dfc2f2
 SpiceGlzDecoderWindow *glz_decoder_window_new(void)
dfc2f2
 {
dfc2f2
-    SpiceGlzDecoderWindow *w = spice_new0(SpiceGlzDecoderWindow, 1);
dfc2f2
+    SpiceGlzDecoderWindow *w = g_new0(SpiceGlzDecoderWindow, 1);
dfc2f2
     glz_decoder_window_clear(w);
dfc2f2
     return w;
dfc2f2
 }
dfc2f2
@@ -461,7 +461,7 @@ void glz_decoder_window_destroy(SpiceGlzDecoderWindow *w)
dfc2f2
 
dfc2f2
 SpiceGlzDecoder *glz_decoder_new(SpiceGlzDecoderWindow *w)
dfc2f2
 {
dfc2f2
-    GlibGlzDecoder *d = spice_new0(GlibGlzDecoder, 1);
dfc2f2
+    GlibGlzDecoder *d = g_new0(GlibGlzDecoder, 1);
dfc2f2
     d->base.ops = &glz_decoder_ops;
dfc2f2
     d->window = w;
dfc2f2
     return &d->base;
dfc2f2
diff --git a/gtk/decode-jpeg.c b/gtk/decode-jpeg.c
dfc2f2
index 85976d0..b86b90c 100644
dfc2f2
--- a/gtk/decode-jpeg.c
dfc2f2
+++ b/gtk/decode-jpeg.c
dfc2f2
@@ -163,7 +163,7 @@ static void jpeg_decoder_term_source (j_decompress_ptr cinfo)
dfc2f2
 
dfc2f2
 SpiceJpegDecoder *jpeg_decoder_new(void)
dfc2f2
 {
dfc2f2
-    GlibJpegDecoder *d = spice_new0(GlibJpegDecoder, 1);
dfc2f2
+    GlibJpegDecoder *d = g_new0(GlibJpegDecoder, 1);
dfc2f2
 
dfc2f2
     d->_cinfo.err = jpeg_std_error(&d->_jerr);
dfc2f2
     jpeg_create_decompress(&d->_cinfo);
dfc2f2
diff --git a/gtk/decode-zlib.c b/gtk/decode-zlib.c
dfc2f2
index a692020..4c56936 100644
dfc2f2
--- a/gtk/decode-zlib.c
dfc2f2
+++ b/gtk/decode-zlib.c
dfc2f2
@@ -55,7 +55,7 @@ static SpiceZlibDecoderOps zlib_decoder_ops = {
dfc2f2
 
dfc2f2
 SpiceZlibDecoder *zlib_decoder_new(void)
dfc2f2
 {
dfc2f2
-    GlibZlibDecoder *d = spice_new0(GlibZlibDecoder, 1);
dfc2f2
+    GlibZlibDecoder *d = g_new0(GlibZlibDecoder, 1);
dfc2f2
     int z_ret;
dfc2f2
 
dfc2f2
     d->_z_strm.zalloc = Z_NULL;
dfc2f2
diff --git a/gtk/spice-channel.c b/gtk/spice-channel.c
dfc2f2
index 1fa42c0..951da65 100644
dfc2f2
--- a/gtk/spice-channel.c
dfc2f2
+++ b/gtk/spice-channel.c
dfc2f2
@@ -507,7 +507,7 @@ void spice_msg_in_unref(SpiceMsgIn *in)
dfc2f2
     if (in->parent) {
dfc2f2
         spice_msg_in_unref(in->parent);
dfc2f2
     } else {
dfc2f2
-        free(in->data);
dfc2f2
+        g_free(in->data);
dfc2f2
     }
dfc2f2
     g_slice_free(SpiceMsgIn, in);
dfc2f2
 }
dfc2f2
@@ -875,7 +875,7 @@ static void spice_channel_write_msg(SpiceChannel *channel, SpiceMsgOut *out)
dfc2f2
     spice_channel_write(channel, data, len);
dfc2f2
 
dfc2f2
     if (free_data)
dfc2f2
-        free(data);
dfc2f2
+        g_free(data);
dfc2f2
 
dfc2f2
     spice_msg_out_unref(out);
dfc2f2
 }
dfc2f2
@@ -1145,7 +1145,7 @@ static void spice_channel_send_link(SpiceChannel *channel)
dfc2f2
     c->link_hdr.size += (c->link_msg.num_common_caps +
dfc2f2
                          c->link_msg.num_channel_caps) * sizeof(uint32_t);
dfc2f2
 
dfc2f2
-    buffer = spice_malloc(sizeof(c->link_hdr) + c->link_hdr.size);
dfc2f2
+    buffer = g_malloc0(sizeof(c->link_hdr) + c->link_hdr.size);
dfc2f2
     p = buffer;
dfc2f2
 
dfc2f2
     memcpy(p, &c->link_hdr, sizeof(c->link_hdr)); p += sizeof(c->link_hdr);
dfc2f2
@@ -1165,7 +1165,7 @@ static void spice_channel_send_link(SpiceChannel *channel)
dfc2f2
                   c->link_msg.num_common_caps,
dfc2f2
                   c->link_msg.num_channel_caps);
dfc2f2
     spice_channel_write(channel, buffer, p - buffer);
dfc2f2
-    free(buffer);
dfc2f2
+    g_free(buffer);
dfc2f2
 }
dfc2f2
 
dfc2f2
 /* coroutine context */
dfc2f2
@@ -1193,7 +1193,7 @@ static gboolean spice_channel_recv_link_hdr(SpiceChannel *channel, gboolean *swi
dfc2f2
         goto error;
dfc2f2
     }
dfc2f2
 
dfc2f2
-    c->peer_msg = spice_malloc(c->peer_hdr.size);
dfc2f2
+    c->peer_msg = g_malloc0(c->peer_hdr.size);
dfc2f2
     if (c->peer_msg == NULL) {
dfc2f2
         g_warning("invalid peer header size: %u", c->peer_hdr.size);
dfc2f2
         goto error;
dfc2f2
@@ -1429,7 +1429,7 @@ static gboolean spice_channel_perform_auth_sasl(SpiceChannel *channel)
dfc2f2
         goto error;
dfc2f2
     }
dfc2f2
 
dfc2f2
-    mechlist = g_malloc(len + 1);
dfc2f2
+    mechlist = g_malloc0(len + 1);
dfc2f2
     spice_channel_read(channel, mechlist, len);
dfc2f2
     mechlist[len] = '\0';
dfc2f2
     if (c->has_error) {
dfc2f2
@@ -1500,7 +1500,7 @@ restart:
dfc2f2
 
dfc2f2
     /* NB, distinction of NULL vs "" is *critical* in SASL */
dfc2f2
     if (len > 0) {
dfc2f2
-        serverin = g_malloc(len);
dfc2f2
+        serverin = g_malloc0(len);
dfc2f2
         spice_channel_read(channel, serverin, len);
dfc2f2
         serverin[len - 1] = '\0';
dfc2f2
         len--;
dfc2f2
@@ -1582,7 +1582,7 @@ restart:
dfc2f2
 
dfc2f2
         /* NB, distinction of NULL vs "" is *critical* in SASL */
dfc2f2
         if (len) {
dfc2f2
-            serverin = g_malloc(len);
dfc2f2
+            serverin = g_malloc0(len);
dfc2f2
             spice_channel_read(channel, serverin, len);
dfc2f2
             serverin[len - 1] = '\0';
dfc2f2
             len--;
dfc2f2
@@ -1782,7 +1782,7 @@ void spice_channel_recv_msg(SpiceChannel *channel,
dfc2f2
     /* FIXME: do not allow others to take ref on in, and use realloc here?
dfc2f2
      * this would avoid malloc/free on each message?
dfc2f2
      */
dfc2f2
-    in->data = spice_malloc(msg_size);
dfc2f2
+    in->data = g_malloc0(msg_size);
dfc2f2
     spice_channel_read(channel, in->data, msg_size);
dfc2f2
     if (c->has_error)
dfc2f2
         goto end;
dfc2f2
@@ -2510,7 +2510,7 @@ static void channel_reset(SpiceChannel *channel, gboolean migrating)
dfc2f2
     }
dfc2f2
     c->fd = -1;
dfc2f2
 
dfc2f2
-    free(c->peer_msg);
dfc2f2
+    g_free(c->peer_msg);
dfc2f2
     c->peer_msg = NULL;
dfc2f2
     c->peer_pos = 0;
dfc2f2
 
dfc2f2
diff --git a/gtk/spice-client-gtk.override b/gtk/spice-client-gtk.override
dfc2f2
index 31e4f9e..41aeee3 100644
dfc2f2
--- a/gtk/spice-client-gtk.override
dfc2f2
+++ b/gtk/spice-client-gtk.override
dfc2f2
@@ -39,21 +39,22 @@ _wrap_spice_display_send_keys(PyGObject *self,
dfc2f2
 	return NULL;
dfc2f2
 
dfc2f2
     len = PyList_Size(keyList);
dfc2f2
-    keys = malloc(sizeof(guint)*len);
dfc2f2
+    keys = g_malloc0(sizeof(guint)*len);
dfc2f2
+
dfc2f2
     for (i = 0 ; i < len ; i++) {
dfc2f2
         PyObject *val;
dfc2f2
         char *sym;
dfc2f2
         val = PyList_GetItem(keyList, i);
dfc2f2
         sym = PyString_AsString(val);
dfc2f2
         if (!sym) {
dfc2f2
-            free(keys);
dfc2f2
+            g_free(keys);
dfc2f2
 	    return NULL;
dfc2f2
         }
dfc2f2
         keys[i] = gdk_keyval_from_name(sym);
dfc2f2
     }
dfc2f2
 
dfc2f2
     spice_display_send_keys(SPICE_DISPLAY(self->obj), keys, len, kind);
dfc2f2
-    free(keys);
dfc2f2
+    g_free(keys);
dfc2f2
 
dfc2f2
     Py_INCREF(Py_None);
dfc2f2
     return Py_None;
dfc2f2
diff --git a/gtk/spice-session.c b/gtk/spice-session.c
dfc2f2
index 9e6c154..6146270 100644
dfc2f2
--- a/gtk/spice-session.c
dfc2f2
+++ b/gtk/spice-session.c
dfc2f2
@@ -1864,7 +1864,7 @@ void spice_session_channel_new(SpiceSession *session, SpiceChannel *channel)
dfc2f2
     g_return_if_fail(s != NULL);
dfc2f2
     g_return_if_fail(channel != NULL);
dfc2f2
 
dfc2f2
-    item = spice_new0(struct channel, 1);
dfc2f2
+    item = g_new0(struct channel, 1);
dfc2f2
     item->channel = channel;
dfc2f2
     ring_add(&s->channels, &item->link);
dfc2f2
 
dfc2f2
diff --git a/gtk/spice-widget.c b/gtk/spice-widget.c
dfc2f2
index 233f36c..7019b03 100644
dfc2f2
--- a/gtk/spice-widget.c
dfc2f2
+++ b/gtk/spice-widget.c
dfc2f2
@@ -2581,7 +2581,7 @@ GdkPixbuf *spice_display_get_pixbuf(SpiceDisplay *display)
dfc2f2
     /* TODO: ensure d->data has been exposed? */
dfc2f2
     g_return_val_if_fail(d->data != NULL, NULL);
dfc2f2
 
dfc2f2
-    data = g_malloc(d->area.width * d->area.height * 3);
dfc2f2
+    data = g_malloc0(d->area.width * d->area.height * 3);
dfc2f2
     src = d->data;
dfc2f2
     dest = data;
dfc2f2
 
dfc2f2
diff --git a/gtk/usb-device-manager.c b/gtk/usb-device-manager.c
dfc2f2
index 1051d10..5013b6c 100644
dfc2f2
--- a/gtk/usb-device-manager.c
dfc2f2
+++ b/gtk/usb-device-manager.c
dfc2f2
@@ -1017,7 +1017,7 @@ static int spice_usb_device_manager_hotplug_cb(libusb_context       *ctx,
dfc2f2
                                                void                 *user_data)
dfc2f2
 {
dfc2f2
     SpiceUsbDeviceManager *self = SPICE_USB_DEVICE_MANAGER(user_data);
dfc2f2
-    struct hotplug_idle_cb_args *args = g_malloc(sizeof(*args));
dfc2f2
+    struct hotplug_idle_cb_args *args = g_malloc0(sizeof(*args));
dfc2f2
 
dfc2f2
     args->self = g_object_ref(self);
dfc2f2
     args->device = libusb_ref_device(device);
dfc2f2
-- 
dfc2f2
1.9.3
dfc2f2