From 183c846b30e842c5c02fe9f51a037a79f9b94d65 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Tue, 27 Feb 2018 12:52:15 +0000 Subject: [PATCH] gnetworkmonitornetlink: Fix memory leaks on error paths Use a common error handler to avoid leaks on the error paths. Signed-off-by: Philip Withnall https://bugzilla.gnome.org/show_bug.cgi?id=793880 --- gio/gnetworkmonitornetlink.c | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/gio/gnetworkmonitornetlink.c b/gio/gnetworkmonitornetlink.c index 2406d219e..12e6627a8 100644 --- a/gio/gnetworkmonitornetlink.c +++ b/gio/gnetworkmonitornetlink.c @@ -313,10 +313,9 @@ read_netlink_messages (GSocket *socket, if (len < 0) { g_warning ("Error on netlink socket: %s", error->message); - g_error_free (error); - if (nl->priv->dump_networks) - finish_dump (nl); - return FALSE; + g_clear_error (&error); + retval = FALSE; + goto done; } iv.buffer = g_malloc (len); @@ -326,21 +325,17 @@ read_netlink_messages (GSocket *socket, if (len < 0) { g_warning ("Error on netlink socket: %s", error->message); - g_clear_object (&addr); - g_error_free (error); - if (nl->priv->dump_networks) - finish_dump (nl); - return FALSE; + g_clear_error (&error); + retval = FALSE; + goto done; } if (!g_socket_address_to_native (addr, &source_sockaddr, sizeof (source_sockaddr), &error)) { g_warning ("Error on netlink socket: %s", error->message); - g_clear_object (&addr); - g_error_free (error); - if (nl->priv->dump_networks) - finish_dump (nl); - return FALSE; + g_clear_error (&error); + retval = FALSE; + goto done; } /* If the sender port id is 0 (not fakeable) then the message is from the kernel */