From: Charlie Brej Date: Sun, 4 Oct 2009 16:56:38 +0000 (+0100) Subject: [script] Do not segfault if accessing array with no key X-Git-Tag: 0.8.0~179 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6c4b2630f0eb9aa97fde693202806a8b92eddabf;p=thirdparty%2Fplymouth.git [script] Do not segfault if accessing array with no key Things like "array[] = 7" would cause a crash. This is now caught and warned about during the parse. --- diff --git a/src/plugins/splash/script/script-parse.c b/src/plugins/splash/script/script-parse.c index bddba474..10eb667d 100644 --- a/src/plugins/splash/script/script-parse.c +++ b/src/plugins/splash/script/script-parse.c @@ -414,6 +414,12 @@ static script_exp_t *script_parse_exp_pi (script_scan_t *scan) { script_scan_get_next_token (scan); key = script_parse_exp (scan); + if (!key) + { + script_parse_error (&curtoken->location, + "Expected a valid index expression"); + return NULL; + } curtoken = script_scan_get_current_token (scan); if (!script_scan_token_is_symbol_of_value (curtoken, ']')) { @@ -670,7 +676,7 @@ static script_op_t *script_parse_do_while (script_scan_t *scan) if (!script_scan_token_is_symbol_of_value (curtoken, ';')) { script_parse_error (&curtoken->location, - "Expected a ';' after a do-whileexpression"); + "Expected a ';' after a do-while expression"); return NULL; } script_scan_get_next_token (scan);