1
0
Fork 0
forked from len0rd/rockbox

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
This commit is contained in:
Nicolas Pennequin 2007-11-12 18:43:38 +00:00
parent 87e5b1193c
commit 8537cbf091

View file

@ -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