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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

Signed-off-by: Fabiano Fidêncio <fidencio@xxxxxxxxxx>
Reviewed-by: Daniel P. Berrangé <berrange@xxxxxxxxxx>
---
 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

_______________________________________________
Libosinfo mailing list
Libosinfo@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libosinfo




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Fedora Users]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]

  Powered by Linux