mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-26 23:46:15 +01:00
gnetworkmonitornetlink: Fix memory leaks on error paths
Use a common error handler to avoid leaks on the error paths. Signed-off-by: Philip Withnall <withnall@endlessm.com> https://bugzilla.gnome.org/show_bug.cgi?id=793880
This commit is contained in:
parent
88bf4939f6
commit
183c846b30
@ -313,10 +313,9 @@ read_netlink_messages (GSocket *socket,
|
|||||||
if (len < 0)
|
if (len < 0)
|
||||||
{
|
{
|
||||||
g_warning ("Error on netlink socket: %s", error->message);
|
g_warning ("Error on netlink socket: %s", error->message);
|
||||||
g_error_free (error);
|
g_clear_error (&error);
|
||||||
if (nl->priv->dump_networks)
|
retval = FALSE;
|
||||||
finish_dump (nl);
|
goto done;
|
||||||
return FALSE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
iv.buffer = g_malloc (len);
|
iv.buffer = g_malloc (len);
|
||||||
@ -326,21 +325,17 @@ read_netlink_messages (GSocket *socket,
|
|||||||
if (len < 0)
|
if (len < 0)
|
||||||
{
|
{
|
||||||
g_warning ("Error on netlink socket: %s", error->message);
|
g_warning ("Error on netlink socket: %s", error->message);
|
||||||
g_clear_object (&addr);
|
g_clear_error (&error);
|
||||||
g_error_free (error);
|
retval = FALSE;
|
||||||
if (nl->priv->dump_networks)
|
goto done;
|
||||||
finish_dump (nl);
|
|
||||||
return FALSE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!g_socket_address_to_native (addr, &source_sockaddr, sizeof (source_sockaddr), &error))
|
if (!g_socket_address_to_native (addr, &source_sockaddr, sizeof (source_sockaddr), &error))
|
||||||
{
|
{
|
||||||
g_warning ("Error on netlink socket: %s", error->message);
|
g_warning ("Error on netlink socket: %s", error->message);
|
||||||
g_clear_object (&addr);
|
g_clear_error (&error);
|
||||||
g_error_free (error);
|
retval = FALSE;
|
||||||
if (nl->priv->dump_networks)
|
goto done;
|
||||||
finish_dump (nl);
|
|
||||||
return FALSE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If the sender port id is 0 (not fakeable) then the message is from the kernel */
|
/* If the sender port id is 0 (not fakeable) then the message is from the kernel */
|
||||||
|
Loading…
Reference in New Issue
Block a user