[tracker/wip/carlosg/coverity-fixes: 2/10] libtracker-data: Make parser check more assertive
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/wip/carlosg/coverity-fixes: 2/10] libtracker-data: Make parser check more assertive
- Date: Wed, 4 Mar 2020 22:21:09 +0000 (UTC)
commit d478d391ad00ffff772f65e61c418b80ca9dc6fe
Author: Carlos Garnacho <carlosg gnome org>
Date: Wed Mar 4 19:17:45 2020 +0100
libtracker-data: Make parser check more assertive
Besides the standard:
'SELECT' '(' Expression 'AS' Var ')'
we support the non-standard:
'SELECT' Expression 'AS' Var
And tried to handle both in the same piece of code. The incongruence
was that we would use _accept(')') on both, in order to catch the
former, but still go through silently on the latter.
Change this code so it's clearer that we do _expect() the closing
parens in the first case. This is merely reassuring as the parser tree
generation stage would catch the real syntax error, but makes code
more in line with the actual intent.
src/libtracker-data/tracker-sparql.c | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
---
diff --git a/src/libtracker-data/tracker-sparql.c b/src/libtracker-data/tracker-sparql.c
index 9c5bde454..84130b916 100644
--- a/src/libtracker-data/tracker-sparql.c
+++ b/src/libtracker-data/tracker-sparql.c
@@ -2438,8 +2438,14 @@ translate_SelectClause (TrackerSparql *sparql,
}
tracker_sparql_swap_builder (sparql, old);
- } else if (_accept (sparql, RULE_TYPE_LITERAL, LITERAL_OPEN_PARENS) ||
- _check_in_rule (sparql, NAMED_RULE_Expression)) {
+ } else {
+ gboolean parens = FALSE;
+
+ if (_accept (sparql, RULE_TYPE_LITERAL, LITERAL_OPEN_PARENS))
+ parens = TRUE;
+ else if (!_check_in_rule (sparql, NAMED_RULE_Expression))
+ break;
+
if (!first)
_append_string (sparql, ", ");
@@ -2460,9 +2466,9 @@ translate_SelectClause (TrackerSparql *sparql,
}
tracker_sparql_swap_builder (sparql, old);
- _accept (sparql, RULE_TYPE_LITERAL, LITERAL_CLOSE_PARENS);
- } else {
- break;
+
+ if (parens)
+ _expect (sparql, RULE_TYPE_LITERAL, LITERAL_CLOSE_PARENS);
}
first = FALSE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]