[Libosinfo] [PATCH osinfo-db-tools 4/7] export: Don't call g_object_unref(NULL) in _create_file()

Fabiano Fidêncio fidencio at redhat.com
Fri Sep 21 09:13:45 UTC 2018


In osinfo_db_create_file() g_file_query_info() may fail which will leave
@info as a NULL and we'll try to free it in the cleanup causing:
(osinfo-db-export:32261): GLib-GObject-CRITICAL **: 11:00:08.488: g_object_unref: assertion 'G_IS_OBJECT (object)' failed

In order to avoid that, let's only call g_object_unref() when @info is
not NULL.

Signed-off-by: Fabiano Fidêncio <fidencio at redhat.com>
---
 tools/osinfo-db-export.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tools/osinfo-db-export.c b/tools/osinfo-db-export.c
index 2c1bb8d..820196f 100644
--- a/tools/osinfo-db-export.c
+++ b/tools/osinfo-db-export.c
@@ -286,7 +286,8 @@ static int osinfo_db_export_create_file(const gchar *prefix,
     g_free(abspath);
     g_free(relpath);
     g_free(entpath);
-    g_object_unref(info);
+    if (info)
+        g_object_unref(info);
     if (err)
         g_error_free(err);
     return ret;
-- 
2.17.1




More information about the Libosinfo mailing list