From 8537cbf091634efa57768dccff39049afdf6d288 Mon Sep 17 00:00:00 2001 From: Nicolas Pennequin Date: Mon, 12 Nov 2007 18:43:38 +0000 Subject: Add detection for a previously ignored error case: a conditional token is present but no conditional start token (e.g. "%?C%al|>"). This would cause an inifnite loop in the displaying code. Thanks to markun for making the mistake and reporting it ;) git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15598 a1c6a512-1295-4272-9138-f99709370657 --- apps/gui/wps_parser.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'apps') diff --git a/apps/gui/wps_parser.c b/apps/gui/wps_parser.c index 86bd096e8c..84e1b185dc 100644 --- a/apps/gui/wps_parser.c +++ b/apps/gui/wps_parser.c @@ -961,6 +961,11 @@ static bool wps_parse(struct wps_data *data, const char *wps_bufptr) data->tokens[data->num_tokens].type = WPS_TOKEN_CONDITIONAL_END; if (lastcond[level]) data->tokens[lastcond[level]].value.i = data->num_tokens; + else + { + fail = PARSE_FAIL_COND_SYNTAX_ERROR; + break; + } lastcond[level] = 0; data->num_tokens++; @@ -979,6 +984,11 @@ static bool wps_parse(struct wps_data *data, const char *wps_bufptr) data->tokens[data->num_tokens].type = WPS_TOKEN_CONDITIONAL_OPTION; if (lastcond[level]) data->tokens[lastcond[level]].value.i = data->num_tokens; + else + { + fail = PARSE_FAIL_COND_SYNTAX_ERROR; + break; + } lastcond[level] = data->num_tokens; numoptions[level]++; @@ -1085,7 +1095,7 @@ static bool wps_parse(struct wps_data *data, const char *wps_bufptr) } } - if (level >= 0) /* there are unclosed conditionals */ + if (!fail && level >= 0) /* there are unclosed conditionals */ fail = PARSE_FAIL_UNCLOSED_COND; #ifdef DEBUG -- cgit v1.2.3