[tracker] libtracker-data: Be more lenient towards NULLs in fn:uri-is-descendant



commit 22bbc9b339edca0386b7cb85ac4e5d48f2e97a1d
Author: Carlos Garnacho <carlosg gnome org>
Date:   Sat Oct 8 14:59:38 2016 +0200

    libtracker-data: Be more lenient towards NULLs in fn:uri-is-descendant
    
    And actually check all arguments, not just first/last. The check is meant
    to catch non-string types (eg. ints, doubles) being wrongly passed here,
    NULLs are more arguably acceptable strings, even if it's to fast path
    to returning FALSE.
    
    This fixes the "Invalid child(0)" errors some users see in gnome-music,
    sometimes the query planner would call the function with a NULL argument
    even though the query would return no results.

 src/libtracker-data/tracker-db-interface-sqlite.c |   16 ++++++++--------
 1 files changed, 8 insertions(+), 8 deletions(-)
---
diff --git a/src/libtracker-data/tracker-db-interface-sqlite.c 
b/src/libtracker-data/tracker-db-interface-sqlite.c
index 6fdc3bb..ff292eb 100644
--- a/src/libtracker-data/tracker-db-interface-sqlite.c
+++ b/src/libtracker-data/tracker-db-interface-sqlite.c
@@ -385,14 +385,14 @@ function_sparql_uri_is_descendant (sqlite3_context *context,
                return;
        }
 
-       if (sqlite3_value_type (argv[argc-1]) != SQLITE_TEXT) {
-               sqlite3_result_error (context, "Invalid child", -1);
-               return;
-       }
-
-       if (sqlite3_value_type (argv[0]) != SQLITE_TEXT) {
-               sqlite3_result_error (context, "Invalid first parent", -1);
-               return;
+       for (i = 0; i < argc; i++) {
+               if (sqlite3_value_type (argv[i]) == SQLITE_NULL) {
+                       sqlite3_result_int (context, FALSE);
+                       return;
+               } else if (sqlite3_value_type (argv[i]) != SQLITE_TEXT) {
+                       sqlite3_result_error (context, "Invalid non-text argument", -1);
+                       return;
+               }
        }
 
        child = sqlite3_value_text (argv[argc-1]);


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