avm2: Do not panic in XMLList call handler

This commit is contained in:
sleepycatcoding 2023-10-13 00:37:12 +03:00 committed by Nathan Adams
parent 8021efaabc
commit 8b5b135a2d
1 changed files with 7 additions and 4 deletions

View File

@ -83,12 +83,15 @@ pub fn call_handler<'gc>(
_this: Object<'gc>,
args: &[Value<'gc>],
) -> Result<Value<'gc>, Error<'gc>> {
// We do *not* create a new object when AS does 'XMLList(someXMLList)'
if let Some(obj) = args.try_get_object(activation, 0) {
if let Some(xml_list) = obj.as_xml_list_object() {
return Ok(xml_list.into());
if args.len() == 1 {
// We do *not* create a new object when AS does 'XMLList(someXMLList)'
if let Some(obj) = args.try_get_object(activation, 0) {
if let Some(xml_list) = obj.as_xml_list_object() {
return Ok(xml_list.into());
}
}
}
Ok(activation
.avm2()
.classes()