[tracker/wip/carlosg/several-fixes: 2/4] libtracker-data: Error out on parser if parse tree ended up empty




commit 0896aeac9e3ba371f7dded304553adcb83f036db
Author: Carlos Garnacho <carlosg gnome org>
Date:   Tue Aug 25 14:06:00 2020 +0200

    libtracker-data: Error out on parser if parse tree ended up empty
    
    After we ended up finishing parsed string, check that the node tree
    actually has any depth before considering it a success. We cannot
    simply check the error stack since it's not uncommon that a correct
    query ends up with accumulated errors from optional elements after
    the query body.
    
    Fixes: https://gitlab.gnome.org/GNOME/tracker/-/issues/237

 src/libtracker-data/tracker-sparql-parser.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
---
diff --git a/src/libtracker-data/tracker-sparql-parser.c b/src/libtracker-data/tracker-sparql-parser.c
index 574058d1d..643da6991 100644
--- a/src/libtracker-data/tracker-sparql-parser.c
+++ b/src/libtracker-data/tracker-sparql-parser.c
@@ -637,7 +637,8 @@ tracker_grammar_parser_read (TrackerGrammarParser *parser,
 
        tracker_parser_state_skip_whitespace (state, parser);
 
-       return parser->query[state->current] == '\0';
+       return (g_node_first_child ((GNode *) state->node_tree->root) > 0 &&
+               parser->query[state->current] == '\0');
 }
 
 static void


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