diff options
author | Nicolas Pennequin <nicolas.pennequin@free.fr> | 2007-11-12 18:43:38 +0000 |
---|---|---|
committer | Nicolas Pennequin <nicolas.pennequin@free.fr> | 2007-11-12 18:43:38 +0000 |
commit | 8537cbf091634efa57768dccff39049afdf6d288 (patch) | |
tree | 91cf0310146af63f02dd900c2f97351390362090 | |
parent | 87e5b1193cf858e2204970b6cce36eb50fefd934 (diff) | |
download | rockbox-8537cbf091634efa57768dccff39049afdf6d288.tar.gz rockbox-8537cbf091634efa57768dccff39049afdf6d288.zip |
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
-rw-r--r-- | apps/gui/wps_parser.c | 12 |
1 files changed, 11 insertions, 1 deletions
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) | |||
961 | data->tokens[data->num_tokens].type = WPS_TOKEN_CONDITIONAL_END; | 961 | data->tokens[data->num_tokens].type = WPS_TOKEN_CONDITIONAL_END; |
962 | if (lastcond[level]) | 962 | if (lastcond[level]) |
963 | data->tokens[lastcond[level]].value.i = data->num_tokens; | 963 | data->tokens[lastcond[level]].value.i = data->num_tokens; |
964 | else | ||
965 | { | ||
966 | fail = PARSE_FAIL_COND_SYNTAX_ERROR; | ||
967 | break; | ||
968 | } | ||
964 | 969 | ||
965 | lastcond[level] = 0; | 970 | lastcond[level] = 0; |
966 | data->num_tokens++; | 971 | data->num_tokens++; |
@@ -979,6 +984,11 @@ static bool wps_parse(struct wps_data *data, const char *wps_bufptr) | |||
979 | data->tokens[data->num_tokens].type = WPS_TOKEN_CONDITIONAL_OPTION; | 984 | data->tokens[data->num_tokens].type = WPS_TOKEN_CONDITIONAL_OPTION; |
980 | if (lastcond[level]) | 985 | if (lastcond[level]) |
981 | data->tokens[lastcond[level]].value.i = data->num_tokens; | 986 | data->tokens[lastcond[level]].value.i = data->num_tokens; |
987 | else | ||
988 | { | ||
989 | fail = PARSE_FAIL_COND_SYNTAX_ERROR; | ||
990 | break; | ||
991 | } | ||
982 | 992 | ||
983 | lastcond[level] = data->num_tokens; | 993 | lastcond[level] = data->num_tokens; |
984 | numoptions[level]++; | 994 | numoptions[level]++; |
@@ -1085,7 +1095,7 @@ static bool wps_parse(struct wps_data *data, const char *wps_bufptr) | |||
1085 | } | 1095 | } |
1086 | } | 1096 | } |
1087 | 1097 | ||
1088 | if (level >= 0) /* there are unclosed conditionals */ | 1098 | if (!fail && level >= 0) /* there are unclosed conditionals */ |
1089 | fail = PARSE_FAIL_UNCLOSED_COND; | 1099 | fail = PARSE_FAIL_UNCLOSED_COND; |
1090 | 1100 | ||
1091 | #ifdef DEBUG | 1101 | #ifdef DEBUG |