From 2e1169bddaa424ae5eef36e2ec12e2a3cb0adc68 Mon Sep 17 00:00:00 2001 From: Nicolas Pennequin Date: Sun, 15 Apr 2007 02:59:34 +0000 Subject: * Make the WPS parser close open conditionals on new sublines and comments as well as new lines. * Make the displaying code check for invalid conditional constructs in order to avoid some rare cases of infinite looping. * Make the WPS parser check that it doesn't read more strings than it can. * Increase the string buffer size (from 512 to 1024, to accomodate the TextBox WPS which uses a lot of unicode characters). git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13162 a1c6a512-1295-4272-9138-f99709370657 --- apps/gui/gwps-common.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'apps/gui/gwps-common.c') diff --git a/apps/gui/gwps-common.c b/apps/gui/gwps-common.c index 6c58c1d666..b4a2cf9596 100644 --- a/apps/gui/gwps-common.c +++ b/apps/gui/gwps-common.c @@ -1279,9 +1279,9 @@ static int find_conditional_end(struct wps_data *data, int index) } int ret = index; - do + while (data->tokens[ret].value.i != 0 + && data->tokens[data->tokens[ret].value.i].type != WPS_TOKEN_CONDITIONAL_END) ret = data->tokens[ret].value.i; - while (data->tokens[ret].type != WPS_TOKEN_CONDITIONAL_END); /* ret now is the index to the end token for the conditional. */ return ret; @@ -1307,6 +1307,10 @@ static int evaluate_conditional(struct gui_wps *gwps, int cond_index) && cond_start < data->num_tokens) cond_start++; + /* if the number of options is 0, the conditional is invalid */ + if (num_options == 0) + return cond_start; + /* treat ?xx constructs as if they had 2 options. */ if (num_options < 2) num_options = 2; -- cgit v1.2.3