]> git.ipfire.org Git - thirdparty/plymouth.git/commitdiff
[script] Do not segfault if accessing array with no key
authorCharlie Brej <cbrej@cs.man.ac.uk>
Sun, 4 Oct 2009 16:56:38 +0000 (17:56 +0100)
committerroot <cbrej@cs.man.ac.uk>
Sun, 4 Oct 2009 16:56:38 +0000 (17:56 +0100)
Things like "array[] = 7" would cause a crash.
This is now caught and warned about during the parse.

src/plugins/splash/script/script-parse.c

index bddba474d2fe8775aec21af2b019e3e0f5cce380..10eb667de85c6125dc7a2e55a7b544395e357f74 100644 (file)
@@ -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);