Преглед изворни кода

Fix out-of-scope goto handling in parser.

Many thanks to Demetrios Obenour for tracking down this long-standing bug.
Mike Pall пре 8 година
родитељ
комит
ff648369aa
1 измењених фајлова са 6 додато и 4 уклоњено
  1. 6 4
      src/lj_parse.c

+ 6 - 4
src/lj_parse.c

@@ -1280,12 +1280,14 @@ static void fscope_end(FuncState *fs)
       MSize idx = gola_new(ls, NAME_BREAK, VSTACK_LABEL, fs->pc);
       MSize idx = gola_new(ls, NAME_BREAK, VSTACK_LABEL, fs->pc);
       ls->vtop = idx;  /* Drop break label immediately. */
       ls->vtop = idx;  /* Drop break label immediately. */
       gola_resolve(ls, bl, idx);
       gola_resolve(ls, bl, idx);
+    } else {  /* Need the fixup step to propagate the breaks. */
+      gola_fixup(ls, bl);
       return;
       return;
-    }  /* else: need the fixup step to propagate the breaks. */
-  } else if (!(bl->flags & FSCOPE_GOLA)) {
-    return;
+    }
+  }
+  if ((bl->flags & FSCOPE_GOLA)) {
+    gola_fixup(ls, bl);
   }
   }
-  gola_fixup(ls, bl);
 }
 }
 
 
 /* Mark scope as having an upvalue. */
 /* Mark scope as having an upvalue. */