[tracker-miners/wip/carlosg/miner-files-queues: 2/10] libtracker-miner: Plug possible leak




commit 8c0a62bed6b133e9ff2b09aba7359f67574d12ec
Author: Carlos Garnacho <carlosg gnome org>
Date:   Wed Dec 15 20:30:39 2021 +0100

    libtracker-miner: Plug possible leak
    
    We sometimes create a GFileInfo (since we don't get any), but we
    fail to unref it.

 src/libtracker-miner/tracker-miner-fs.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
---
diff --git a/src/libtracker-miner/tracker-miner-fs.c b/src/libtracker-miner/tracker-miner-fs.c
index 794e15c17..0c8dc8950 100644
--- a/src/libtracker-miner/tracker-miner-fs.c
+++ b/src/libtracker-miner/tracker-miner-fs.c
@@ -1068,16 +1068,17 @@ item_add_or_update (TrackerMinerFS *fs,
 {
        gchar *uri;
 
-       if (!info) {
+       if (info) {
+               g_object_ref (info);
+       } else {
                info = g_file_query_info (file,
                                          fs->priv->file_attributes,
                                          G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
                                          NULL, NULL);
+               if (!info)
+                       return TRUE;
        }
 
-       if (!info)
-               return TRUE;
-
        uri = g_file_get_uri (file);
 
        if (!attributes_update) {
@@ -1094,6 +1095,7 @@ item_add_or_update (TrackerMinerFS *fs,
        fs->priv->total_files_processed++;
 
        g_free (uri);
+       g_object_unref (info);
 
        return TRUE;
 }


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