Skip to content

Commit

Permalink
Panic if catch_exception is called incorrectly
Browse files Browse the repository at this point in the history
  • Loading branch information
voltrevo committed Jul 18, 2024
1 parent 00ec3c1 commit 4de7198
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions valuescript_vm/src/bytecode_stack_frame.rs
Original file line number Diff line number Diff line change
Expand Up @@ -714,16 +714,19 @@ impl StackFrameTrait for BytecodeStackFrame {
}

fn catch_exception(&mut self, exception: &mut Val) {
if let Some(catch_setting) = &self.catch_setting {
let exception = take(exception);
let catch_setting = self
.catch_setting
.as_ref()
.expect("can_catch_exception should have been checked before calling this");

if let Some(r) = catch_setting.register {
self.registers[r] = exception;
}
let exception = take(exception);

self.decoder.pos = catch_setting.pos;
self.catch_setting = None;
if let Some(r) = catch_setting.register {
self.registers[r] = exception;
}

self.decoder.pos = catch_setting.pos;
self.catch_setting = None;
}

fn clone_to_stack_frame(&self) -> StackFrame {
Expand Down

0 comments on commit 4de7198

Please sign in to comment.