core: Made SwfSlice::to_unbounded_subslice return an empty slice in case of errors
This commit is contained in:
parent
55566037f7
commit
44cfaa9200
|
@ -861,7 +861,7 @@ impl<'a, 'gc, 'gc_context> Activation<'a, 'gc, 'gc_context> {
|
|||
parent_data: &SwfSlice,
|
||||
) -> Result<FrameControl<'gc>, Error<'gc>> {
|
||||
let swf_version = self.swf_version();
|
||||
let func_data = parent_data.to_unbounded_subslice(action.actions).unwrap();
|
||||
let func_data = parent_data.to_unbounded_subslice(action.actions);
|
||||
let constant_pool = self.constant_pool();
|
||||
let func = Avm1Function::from_swf_function(
|
||||
self.context.gc_context,
|
||||
|
@ -2124,8 +2124,7 @@ impl<'a, 'gc, 'gc_context> Activation<'a, 'gc, 'gc_context> {
|
|||
action: &Try,
|
||||
parent_data: &SwfSlice,
|
||||
) -> Result<FrameControl<'gc>, Error<'gc>> {
|
||||
let mut result =
|
||||
self.run_actions(parent_data.to_unbounded_subslice(action.try_body).unwrap());
|
||||
let mut result = self.run_actions(parent_data.to_unbounded_subslice(action.try_body));
|
||||
|
||||
if let Some((catch_vars, actions)) = &action.catch_body {
|
||||
if let Err(Error::ThrownValue(value)) = &result {
|
||||
|
@ -2151,14 +2150,13 @@ impl<'a, 'gc, 'gc_context> Activation<'a, 'gc, 'gc_context> {
|
|||
}
|
||||
}
|
||||
|
||||
result =
|
||||
activation.run_actions(parent_data.to_unbounded_subslice(actions).unwrap());
|
||||
result = activation.run_actions(parent_data.to_unbounded_subslice(actions));
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(actions) = action.finally_body {
|
||||
if let ReturnType::Explicit(value) =
|
||||
self.run_actions(parent_data.to_unbounded_subslice(actions).unwrap())?
|
||||
self.run_actions(parent_data.to_unbounded_subslice(actions))?
|
||||
{
|
||||
return Ok(FrameControl::Return(ReturnType::Explicit(value)));
|
||||
}
|
||||
|
@ -2212,7 +2210,7 @@ impl<'a, 'gc, 'gc_context> Activation<'a, 'gc, 'gc_context> {
|
|||
action: With,
|
||||
parent_data: &SwfSlice,
|
||||
) -> Result<FrameControl<'gc>, Error<'gc>> {
|
||||
let code = parent_data.to_unbounded_subslice(action.actions).unwrap();
|
||||
let code = parent_data.to_unbounded_subslice(action.actions);
|
||||
let value = self.context.avm1.pop();
|
||||
match value {
|
||||
// Undefined/null with is ignored.
|
||||
|
|
|
@ -46,9 +46,7 @@ impl<'gc> Avm1Button<'gc> {
|
|||
) -> Self {
|
||||
let mut actions = vec![];
|
||||
for action in &button.actions {
|
||||
let action_data = source_movie
|
||||
.to_unbounded_subslice(action.action_data)
|
||||
.unwrap();
|
||||
let action_data = source_movie.to_unbounded_subslice(action.action_data);
|
||||
let bits = action.conditions.bits();
|
||||
let mut bit = 1u16;
|
||||
while bits & !(bit - 1) != 0 {
|
||||
|
|
|
@ -3563,9 +3563,7 @@ impl ClipEventHandler {
|
|||
} else {
|
||||
ButtonKeyCode::Unknown
|
||||
};
|
||||
let action_data = SwfSlice::from(movie)
|
||||
.to_unbounded_subslice(other.action_data)
|
||||
.unwrap();
|
||||
let action_data = SwfSlice::from(movie).to_unbounded_subslice(other.action_data);
|
||||
Self {
|
||||
events: other.events,
|
||||
key_code,
|
||||
|
|
|
@ -143,11 +143,7 @@ impl<'gc> Video<'gc> {
|
|||
log::warn!("Duplicate frame {}", tag.frame_num);
|
||||
}
|
||||
|
||||
if let Some(subslice) = subslice {
|
||||
frames.insert(tag.frame_num.into(), (subslice.start, subslice.end));
|
||||
} else {
|
||||
log::warn!("Invalid bitstream subslice on frame {}", tag.frame_num);
|
||||
}
|
||||
frames.insert(tag.frame_num.into(), (subslice.start, subslice.end));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -224,19 +224,19 @@ impl SwfSlice {
|
|||
///
|
||||
/// This function allows subslices outside the current slice to be formed,
|
||||
/// as long as they are valid subslices of the movie itself.
|
||||
pub fn to_unbounded_subslice(&self, slice: &[u8]) -> Option<Self> {
|
||||
pub fn to_unbounded_subslice(&self, slice: &[u8]) -> Self {
|
||||
let self_pval = self.movie.data().as_ptr() as usize;
|
||||
let self_len = self.movie.data().len();
|
||||
let slice_pval = slice.as_ptr() as usize;
|
||||
|
||||
if self_pval <= slice_pval && slice_pval < (self_pval + self_len) {
|
||||
Some(Self {
|
||||
Self {
|
||||
movie: self.movie.clone(),
|
||||
start: slice_pval - self_pval,
|
||||
end: (slice_pval - self_pval) + slice.len(),
|
||||
})
|
||||
}
|
||||
} else {
|
||||
None
|
||||
self.copy_empty()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue