[tracker/wip/carlosg/coverity-fixes: 4/16] tracker: Test return value of g_file_get_contents()




commit b3f284f231297e8771c29017f06aaeb6b5b2d515
Author: Carlos Garnacho <carlosg gnome org>
Date:   Sat Oct 23 00:11:05 2021 +0200

    tracker: Test return value of g_file_get_contents()
    
    Check for the return value of this function, since coverity seems
    to like it checked (and does not understand the error is only filled
    in case of error).
    
    CID: #1501105

 src/tracker/tracker-sparql.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
---
diff --git a/src/tracker/tracker-sparql.c b/src/tracker/tracker-sparql.c
index 04fcdff71..48b925fe0 100644
--- a/src/tracker/tracker-sparql.c
+++ b/src/tracker/tracker-sparql.c
@@ -1428,8 +1428,8 @@ sparql_run (void)
                        goto out;
                }
 
-               g_file_get_contents (path_in_utf8, &query, &size, &error);
-               if (error) {
+               if (!g_file_get_contents (path_in_utf8, &query, &size, &error)) {
+                       g_assert (error != NULL);
                        g_printerr ("%s:'%s', %s\n",
                                    _("Could not read file"),
                                    path_in_utf8,


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