Skip to content

Commit

Permalink
avm1: Support FLV date conversion
Browse files Browse the repository at this point in the history
Fixes Riva Web Player crash (rivavx.de)
  • Loading branch information
mtc-mlx authored and kmeisthax committed Dec 11, 2023
1 parent 512a038 commit 06646bc
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions core/src/avm1/flv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,17 @@ fn avm1_object_from_flv_variables<'gc>(
info_object.into()
}

fn avm1_date_from_flv_date<'gc>(
activation: &mut Activation<'_, 'gc>,
unix_time: f64,
_local_offset: i16,
) -> Avm1Value<'gc> {
let constructor = activation.context.avm1.prototypes().date_constructor;
let result = constructor.construct(activation, &[unix_time.into()]);

result.expect("AVM1 date constructed from FLV date")
}

fn avm1_array_from_flv_values<'gc>(
activation: &mut Activation<'_, 'gc>,
values: Vec<FlvValue>,
Expand All @@ -50,6 +61,10 @@ impl<'gc> FlvValueAvm1Ext<'gc> for FlvValue<'_> {
FlvValue::String(string_data) | FlvValue::LongString(string_data) => {
AvmString::new_utf8_bytes(activation.context.gc_context, string_data).into()
}
FlvValue::Date {
unix_time,
local_offset,
} => avm1_date_from_flv_date(activation, unix_time, local_offset),
FlvValue::Number(value) => value.into(),
FlvValue::Boolean(value) => value.into(),
FlvValue::Null => Avm1Value::Null,
Expand Down

0 comments on commit 06646bc

Please sign in to comment.