avm2: Fix invalid option

This commit is contained in:
Jean Marchand 2022-02-12 21:34:25 +01:00 committed by relrelb
parent ad2b8ea007
commit 9969e0ce5a
2 changed files with 3 additions and 6 deletions

View File

@ -781,7 +781,7 @@ impl<'a, 'gc, 'gc_context> Activation<'a, 'gc, 'gc_context> {
let instruction_start = reader.pos(full_data); let instruction_start = reader.pos(full_data);
let op = reader.read_op(); let op = reader.read_op();
if let Ok(Some(op)) = op { if let Ok(op) = op {
avm_debug!(self.avm2(), "Opcode: {:?}", op); avm_debug!(self.avm2(), "Opcode: {:?}", op);
let result = match op { let result = match op {
@ -971,9 +971,6 @@ impl<'a, 'gc, 'gc_context> Activation<'a, 'gc, 'gc_context> {
return Err(e); return Err(e);
} }
result result
} else if let Ok(None) = op {
log::error!("Unknown opcode!");
Err("Unknown opcode!".into())
} else if let Err(e) = op { } else if let Err(e) = op {
log::error!("Parse error: {:?}", e); log::error!("Parse error: {:?}", e);
Err(e.into()) Err(e.into())

View File

@ -501,7 +501,7 @@ impl<'a> Reader<'a> {
}) })
} }
pub fn read_op(&mut self) -> Result<Option<Op>> { pub fn read_op(&mut self) -> Result<Op> {
use crate::avm2::opcode::OpCode; use crate::avm2::opcode::OpCode;
use num_traits::FromPrimitive; use num_traits::FromPrimitive;
@ -858,7 +858,7 @@ impl<'a> Reader<'a> {
OpCode::URShift => Op::URShift, OpCode::URShift => Op::URShift,
}; };
Ok(Some(op)) Ok(op)
} }
fn read_exception(&mut self) -> Result<Exception> { fn read_exception(&mut self) -> Result<Exception> {