From 14dba0d1001245a480e51d4c6ffef2cd6c86a3ee Mon Sep 17 00:00:00 2001 From: David Wendt Date: Sun, 5 Jan 2020 00:04:45 -0500 Subject: [PATCH] Log errors encountered when removing the children of a node we plan to parse XML into. Also, remove a handful of unnecessary `#[allow(unused_must_use)]` instances. --- core/src/avm1/globals/xml.rs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/core/src/avm1/globals/xml.rs b/core/src/avm1/globals/xml.rs index 6db77927b..cf64a3e77 100644 --- a/core/src/avm1/globals/xml.rs +++ b/core/src/avm1/globals/xml.rs @@ -184,7 +184,6 @@ pub fn xmlnode_has_child_nodes<'gc>( } } -#[allow(unused_must_use)] pub fn xmlnode_remove_node<'gc>( _avm: &mut Avm1<'gc>, ac: &mut UpdateContext<'_, 'gc, '_>, @@ -202,7 +201,6 @@ pub fn xmlnode_remove_node<'gc>( Ok(Value::Undefined.into()) } -#[allow(unused_must_use)] pub fn xmlnode_to_string<'gc>( _avm: &mut Avm1<'gc>, _ac: &mut UpdateContext<'_, 'gc, '_>, @@ -611,7 +609,6 @@ pub fn xml_constructor<'gc>( Ok(Value::Undefined.into()) } -#[allow(unused_must_use)] pub fn xml_create_element<'gc>( avm: &mut Avm1<'gc>, ac: &mut UpdateContext<'_, 'gc, '_>, @@ -640,7 +637,6 @@ pub fn xml_create_element<'gc>( Ok(object.into()) } -#[allow(unused_must_use)] pub fn xml_create_text_node<'gc>( avm: &mut Avm1<'gc>, ac: &mut UpdateContext<'_, 'gc, '_>, @@ -669,7 +665,6 @@ pub fn xml_create_text_node<'gc>( Ok(object.into()) } -#[allow(unused_must_use)] pub fn xml_parse_xml<'gc>( avm: &mut Avm1<'gc>, ac: &mut UpdateContext<'_, 'gc, '_>, @@ -686,7 +681,11 @@ pub fn xml_parse_xml<'gc>( if let Some(children) = node.children() { for child in children.rev() { - node.remove_child(ac.gc_context, child); + let result = node.remove_child(ac.gc_context, child); + if let Err(e) = result { + log::warn!("XML.parseXML: Error removing node contents: {}", e); + return Ok(Value::Undefined.into()); + } } }