From 2f5dd509c4a82873b4bf626e55d9c6624ec43dfc Mon Sep 17 00:00:00 2001 From: dec05eba Date: Fri, 10 Sep 2021 17:25:03 +0200 Subject: Fix indexing when no param is defined --- src/XpathParser.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/XpathParser.c b/src/XpathParser.c index b79fe11..b69e47d 100644 --- a/src/XpathParser.c +++ b/src/XpathParser.c @@ -36,19 +36,25 @@ static int xpath_parse_param(QuickMediaXpathParser *self, QuickMediaNodeSearchPa return -3; result->value = self->tokenizer.string; + + token = quickmedia_xpath_tokenizer_next(&self->tokenizer); + if(token != QUICKMEDIA_XPATH_TOKEN_CLOSING_BRACKET) + return -4; + + result->defined = 1; + result->value_is_glob = contains_glob_char(result->value); + return 0; } else if(token == QUICKMEDIA_XPATH_TOKEN_NUMBER) { result->index = self->tokenizer.number; + + token = quickmedia_xpath_tokenizer_next(&self->tokenizer); + if(token != QUICKMEDIA_XPATH_TOKEN_CLOSING_BRACKET) + return -4; + + return 0; } else { return -1; } - - token = quickmedia_xpath_tokenizer_next(&self->tokenizer); - if(token != QUICKMEDIA_XPATH_TOKEN_CLOSING_BRACKET) - return -4; - - result->defined = 1; - result->value_is_glob = contains_glob_char(result->value); - return 0; } /* ('[' NUMBER ']'))? */ -- cgit v1.2.3