Skip to content

Commit 802d343

Browse files
committed
fix thug2 switch statements
1 parent dddc034 commit 802d343

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

Source/QCompile.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,8 @@ namespace QScript
244244
if (i != 0)
245245
set_short_address(case_addr - 2, bytecode.size() + 1);
246246
}
247+
248+
switch_stack.pop();
247249
}
248250

249251
// Push EndSwitch
@@ -561,6 +563,8 @@ namespace QScript
561563
g_tokens.clear();
562564

563565
// Check if stacks are empty
566+
if (!switch_stack.empty())
567+
throw std::runtime_error("Unexpected end of script (missing 'ENDSWITCH')");
564568
if (!random_stack.empty())
565569
throw std::runtime_error("Unexpected end of script (missing 'RANDOMEND')");
566570
if (!short_stack.empty())

0 commit comments

Comments
 (0)