[Spice-devel] [spice-gtk] Fix various memory leaks
Alon Levy
alevy at redhat.com
Wed Jun 13 03:37:22 PDT 2012
On Wed, Jun 13, 2012 at 12:15:39PM +0200, Christophe Fergeau wrote:
> ==25063== 12,827 (2,032 direct, 10,795 indirect) bytes in 127 blocks are definitely lost in loss record 9,477 of 9,502
> ==25063== at 0x4A0884D: malloc (vg_replace_malloc.c:263)
> ==25063== by 0x3DE384D2BE: g_malloc (gmem.c:159)
> ==25063== by 0x3DE38616B1: g_slice_alloc (gslice.c:1003)
> ==25063== by 0x3DE38346B0: g_error_new_valist (gerror.c:393)
> ==25063== by 0x3DE3834A8C: g_set_error (gerror.c:560)
> ==25063== by 0x3DE4871108: g_socket_receive_with_blocking (gsocket.c:2513)
> ==25063== by 0x5B708E8: bio_gsocket_bread (bio-gsocket.c:56)
> ==25063== by 0x61AEBD8: BIO_read (bio_lib.c:212)
> ==25063== by 0x5ECAC5B: ssl3_read_n (s3_pkt.c:238)
> ==25063== by 0x5ECBD3D: ssl3_read_bytes (s3_pkt.c:318)
> ==25063== by 0x5ECD6CF: ssl3_get_message (s3_both.c:426)
> ==25063== by 0x5EC5AFB: ssl3_get_new_session_ticket (s3_clnt.c:1822)
>
> ==25063== 90 bytes in 3 blocks are definitely lost in loss record 7,354 of 9,502
> ==25063== at 0x4A0884D: malloc (vg_replace_malloc.c:263)
> ==25063== by 0x3DE384D2BE: g_malloc (gmem.c:159)
> ==25063== by 0x3DE3862D0B: g_strdup (gstrfuncs.c:356)
> ==25063== by 0x5B961B5: spice_usb_device_manager_set_property (usb-device-manager.c:306)
> ==25063== by 0x3DE40148FB: g_object_constructor (gobject.c:1352)
> ==25063== by 0x3DE4015D70: g_object_newv (gobject.c:1713)
> ==25063== by 0x3DE401655F: g_object_new_valist (gobject.c:1830)
> ==25063== by 0x3DE485924D: g_initable_new_valist (ginitable.c:224)
> ==25063== by 0x3DE4859348: g_initable_new (ginitable.c:148)
> ==25063== by 0x5B97330: spice_usb_device_manager_get (usb-device-manager.c:770)
> ==25063== by 0x52D8C6B: spice_gtk_session_update_keyboard_focus (spice-gtk-session.c:845)
> ==25063== by 0x52D6DC1: spice_gtk_session_set_property (spice-gtk-session.c:238)
>
> ==25063== 120 bytes in 3 blocks are definitely lost in loss record 8,448 of 9,502
> ==25063== at 0x4A06F18: calloc (vg_replace_malloc.c:566)
> ==25063== by 0x68BB2E5: usbredirfilter_string_to_rules (usbredirfilter.c:54)
> ==25063== by 0x5B96123: spice_usb_device_manager_set_property (usb-device-manager.c:293)
> ==25063== by 0x3DE40148FB: g_object_constructor (gobject.c:1352)
> ==25063== by 0x3DE4015D70: g_object_newv (gobject.c:1713)
> ==25063== by 0x3DE401655F: g_object_new_valist (gobject.c:1830)
> ==25063== by 0x3DE485924D: g_initable_new_valist (ginitable.c:224)
> ==25063== by 0x3DE4859348: g_initable_new (ginitable.c:148)
> ==25063== by 0x5B97330: spice_usb_device_manager_get (usb-device-manager.c:770)
> ==25063== by 0x52D8C6B: spice_gtk_session_update_keyboard_focus (spice-gtk-session.c:845)
> ==25063== by 0x52D6DC1: spice_gtk_session_set_property (spice-gtk-session.c:238)
> ==25063== by 0x3DE40148FB: g_object_constructor (gobject.c:1352)
>
> ==25063== 11,959 (72 direct, 11,887 indirect) bytes in 1 blocks are definitely lost in loss record 9,475 of 9,502
> ==25063== at 0x4A06F18: calloc (vg_replace_malloc.c:566)
> ==25063== by 0x3459C92DDC: XkbGetKeyboardByName (XKBGetByName.c:59)
> ==25063== by 0x52DF000: vnc_display_keymap_gdk2xtkbd_table (vncdisplaykeymap.c:153)
> ==25063== by 0x52D9FA6: spice_display_init (spice-widget.c:389)
> ==25063== by 0x3DE402FA05: g_type_create_instance (gtype.c:1892)
> ==25063== by 0x3DE40147A7: g_object_constructor (gobject.c:1849)
> ==25063== by 0x52DA07B: spice_display_constructor (spice-widget.c:412)
> ==25063== by 0x3DE4015D70: g_object_newv (gobject.c:1713)
> ==25063== by 0x3DE401655F: g_object_new_valist (gobject.c:1830)
> ==25063== by 0x3DE4016893: g_object_new (gobject.c:1545)
> ==25063== by 0x52DE746: spice_display_new (spice-widget.c:1924)
> ==25063== by 0x41D6C3: virt_viewer_display_spice_new (virt-viewer-display-spice.c:219)
> ---
> gtk/bio-gsocket.c | 6 +++---
> gtk/usb-device-manager.c | 3 +++
> gtk/vncdisplaykeymap.c | 2 +-
> 3 files changed, 7 insertions(+), 4 deletions(-)
>
> diff --git a/gtk/bio-gsocket.c b/gtk/bio-gsocket.c
> index ce94afe..dbf17a2 100644
> --- a/gtk/bio-gsocket.c
> +++ b/gtk/bio-gsocket.c
> @@ -59,10 +59,10 @@ static int bio_gsocket_bread(BIO *bio, char *out, int outl)
>
> if (g_error_matches(error, G_IO_ERROR, G_IO_ERROR_WOULD_BLOCK))
> BIO_set_retry_read(bio);
> - else if (error != NULL) {
> + else if (error != NULL)
> g_warning("%s", error->message);
> - g_clear_error(&error);
> - }
> +
> + g_clear_error(&error);
>
> return ret;
> }
> diff --git a/gtk/usb-device-manager.c b/gtk/usb-device-manager.c
> index 14b60c9..a3e6ff9 100644
> --- a/gtk/usb-device-manager.c
> +++ b/gtk/usb-device-manager.c
> @@ -235,6 +235,9 @@ static void spice_usb_device_manager_finalize(GObject *gobject)
> g_thread_join(priv->event_thread);
> #endif
>
> + g_free(priv->auto_connect_filter);
> + free(priv->auto_conn_filter_rules);
> +
> /* Chain up to the parent class */
> if (G_OBJECT_CLASS(spice_usb_device_manager_parent_class)->finalize)
> G_OBJECT_CLASS(spice_usb_device_manager_parent_class)->finalize(gobject);
> diff --git a/gtk/vncdisplaykeymap.c b/gtk/vncdisplaykeymap.c
> index 26a71a4..a6ef38c 100644
> --- a/gtk/vncdisplaykeymap.c
> +++ b/gtk/vncdisplaykeymap.c
> @@ -159,7 +159,7 @@ const guint16 const *vnc_display_keymap_gdk2xtkbd_table(size_t *maplen)
> if (!keycodes)
> g_warning("could not lookup keycode name");
> }
> - XkbFreeClientMap(desc, XkbGBN_AllComponentsMask, True);
> + XkbFreeKeyboard(desc, XkbGBN_AllComponentsMask, True);
Probably worth to hunt down the original copy and fix that too.
> }
>
> if (check_for_xwin(dpy)) {
> --
> 1.7.10.2
>
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/spice-devel
More information about the Spice-devel
mailing list