From a9172c6d03de138fb91456b86adec23bf9421467 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Mon, 11 Jul 2016 21:56:04 +0100 Subject: [PATCH] gio-tool: Fix memory leaks on error paths in mount command Various GErrors were being leaked. Coverity CID: 1357351 (amongst others) --- gio/gio-tool-mount.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/gio/gio-tool-mount.c b/gio/gio-tool-mount.c index 9f5b217a6..92d16c104 100644 --- a/gio/gio-tool-mount.c +++ b/gio/gio-tool-mount.c @@ -246,6 +246,8 @@ mount_mountable_done_cb (GObject *object, g_printerr (_("Error mounting location: Anonymous access denied\n")); else if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_FAILED_HANDLED)) g_printerr (_("Error mounting location: %s\n"), error->message); + + g_error_free (error); } else g_object_unref (target); @@ -274,6 +276,8 @@ mount_done_cb (GObject *object, g_printerr (_("Error mounting location: Anonymous access denied\n")); else if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_FAILED_HANDLED)) g_printerr (_("Error mounting location: %s\n"), error->message); + + g_error_free (error); } outstanding_mounts--; @@ -336,6 +340,7 @@ unmount_done_cb (GObject *object, { g_printerr (_("Error unmounting mount: %s\n"), error->message); success = FALSE; + g_error_free (error); } outstanding_mounts--; @@ -360,6 +365,7 @@ unmount (GFile *file) { g_printerr (_("Error finding enclosing mount: %s\n"), error->message); success = FALSE; + g_error_free (error); return; } @@ -387,6 +393,7 @@ eject_done_cb (GObject *object, { g_printerr (_("Error ejecting mount: %s\n"), error->message); success = FALSE; + g_error_free (error); } outstanding_mounts--; @@ -411,6 +418,7 @@ eject (GFile *file) { g_printerr (_("Error finding enclosing mount: %s\n"), error->message); success = FALSE; + g_error_free (error); return; } @@ -867,6 +875,7 @@ mount_with_device_file_cb (GObject *object, g_printerr (_("Error mounting %s: %s\n"), g_volume_get_identifier (volume, G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE), error->message); + g_error_free (error); success = FALSE; } else