]> git.xonotic.org Git - xonotic/gmqcc.git/blobdiff - parser.c
fixing a crash caused by the correction: setting correct=NULL after freeing so the...
[xonotic/gmqcc.git] / parser.c
index d374af7329a2a272ddc1cc3a0ce31e1a2fe305ee..6c59d3ca7c73cf555aeae84e6cb1a13064de5439 100644 (file)
--- a/parser.c
+++ b/parser.c
@@ -1649,6 +1649,7 @@ static ast_expression* parse_expression_leave(parser_t *parser, bool stopatcomma
                                 break;
                             } else if (correct) {
                                 mem_d(correct);
+                                correct = NULL;
                             }
                         }
 
@@ -2644,6 +2645,13 @@ static bool parse_break_continue(parser_t *parser, ast_block *block, ast_express
         return false;
     }
 
+    if (!vec_size(loops)) {
+        if (is_continue)
+            parseerror(parser, "`continue` can only be used inside loops");
+        else
+            parseerror(parser, "`break` can only be used inside loops or switches");
+    }
+
     if (parser->tok == TOKEN_IDENT) {
         if (!OPTS_FLAG(LOOP_LABELS))
             parseerror(parser, "labeled loops not activated, try using -floop-labels");