[Libosinfo] [libosinfo PATCH v2 1/6] media: Don't leak stream in case of errors

Fabiano Fidêncio fidencio at redhat.com
Thu Dec 20 07:46:42 UTC 2018


stream has to be freed whenever an error occurr on
osinfo_media_create_from_location_async() internals.

Signed-off-by: Fabiano Fidêncio <fidencio at redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange at redhat.com>
---
 osinfo/osinfo_media.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/osinfo/osinfo_media.c b/osinfo/osinfo_media.c
index 519f8ab..fd5e622 100644
--- a/osinfo/osinfo_media.c
+++ b/osinfo/osinfo_media.c
@@ -894,6 +894,7 @@ static void on_pvd_read(GObject *source,
     return;
 
 ON_ERROR:
+    g_object_unref(stream);
     g_task_return_error(data->res, error);
     create_from_location_async_data_free(data);
 }
@@ -916,6 +917,7 @@ static void on_location_skipped(GObject *source,
                         OSINFO_MEDIA_ERROR,
                         OSINFO_MEDIA_ERROR_NO_DESCRIPTORS,
                         _("No volume descriptors"));
+        g_object_unref(stream);
         g_task_return_error(data->res, error);
         create_from_location_async_data_free(data);
 
@@ -947,6 +949,7 @@ static void on_location_read(GObject *source,
     stream = g_file_read_finish(G_FILE(source), res, &error);
     if (error != NULL) {
         g_prefix_error(&error, _("Failed to open file"));
+        g_object_unref(stream);
         g_task_return_error(data->res, error);
         create_from_location_async_data_free(data);
 
-- 
2.19.1




More information about the Libosinfo mailing list