[gnome-autoar/wip/oholy/extractor-null-dereference] extractor: Prevent NULL dereference when extracting to root




commit a5683af1e418cef6569951b2f62135f8a6b6fd02
Author: Ondrej Holy <oholy redhat com>
Date:   Mon Feb 7 10:17:54 2022 +0100

    extractor: Prevent NULL dereference when extracting to root
    
    This is followup of the commit 7237276. The extraction to root can still
    lead to crashes because the `parent` variable is `NULL` and is consequently
    passed into the `g_object_unref` function. Let's finally fix this corner
    case properly.

 gnome-autoar/autoar-extractor.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
---
diff --git a/gnome-autoar/autoar-extractor.c b/gnome-autoar/autoar-extractor.c
index 9cd52bd..35bb4ad 100644
--- a/gnome-autoar/autoar-extractor.c
+++ b/gnome-autoar/autoar-extractor.c
@@ -991,11 +991,13 @@ autoar_extractor_do_write_entry (AutoarExtractor      *self,
   {
     GFile *parent;
     parent = g_file_get_parent (dest);
-    if (parent && !g_file_query_exists (parent, self->cancellable))
-      g_file_make_directory_with_parents (parent,
-                                          self->cancellable,
-                                          NULL);
-    g_object_unref (parent);
+    if (parent) {
+      if (!g_file_query_exists (parent, self->cancellable))
+        g_file_make_directory_with_parents (parent,
+                                            self->cancellable,
+                                            NULL);
+      g_object_unref (parent);
+    }
   }
 
   info = g_file_info_new ();


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