[tracker/wip/carlosg/coverity-fixes: 10/16] tracker: Check the return value of g_filename_to_utf8()




commit 854e03382537353fdee07fcd52334b26817ca275
Author: Carlos Garnacho <carlosg gnome org>
Date:   Sat Oct 23 13:59:36 2021 +0200

    tracker: Check the return value of g_filename_to_utf8()
    
    We were checking for the error here, but Coverity seems to insist
    that we are not freeing the possibly returned string. This is
    obviously not true, since NULL will be returned on error. Check
    on both things to appease Coverity.
    
    CID: #1501121

 src/tracker/tracker-sparql.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
---
diff --git a/src/tracker/tracker-sparql.c b/src/tracker/tracker-sparql.c
index 48b925fe0..b76e99ecd 100644
--- a/src/tracker/tracker-sparql.c
+++ b/src/tracker/tracker-sparql.c
@@ -1417,7 +1417,8 @@ sparql_run (void)
                gsize size;
 
                path_in_utf8 = g_filename_to_utf8 (file, -1, NULL, NULL, &error);
-               if (error) {
+               if (!path_in_utf8) {
+                       g_assert (error != NULL);
                        g_printerr ("%s:'%s', %s\n",
                                    _("Could not get UTF-8 path from path"),
                                    file,


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