diff --git a/swf/src/avm1/read.rs b/swf/src/avm1/read.rs index 997fd7b1d..9b4b6c83a 100644 --- a/swf/src/avm1/read.rs +++ b/swf/src/avm1/read.rs @@ -404,6 +404,19 @@ pub mod tests { } } + /// Ensure that we return an error on invalid data. + #[test] + fn read_parse_error() { + let action_bytes = [0xff, 0xff, 0xff, 0x00, 0x00]; + let mut reader = Reader::new(&action_bytes[..], 5); + match reader.read_action() { + Err(crate::error::Error::Avm1ParseError { .. }) => (), + result => { + panic!("Expected Avm1ParseError, got {:?}", result); + } + } + } + #[test] fn read_define_function() { // Ensure we read a function properly along with the function data. diff --git a/swf/src/read.rs b/swf/src/read.rs index c6838030b..2c4cd1616 100644 --- a/swf/src/read.rs +++ b/swf/src/read.rs @@ -3136,4 +3136,17 @@ pub mod tests { assert_eq!(reader.read_tag_list().unwrap(), [Tag::ShowFrame]); } } + + /// Ensure that we return an error on invalid data. + #[test] + fn read_invalid_tag() { + let tag_bytes = [0xff, 0xff, 0xff, 0xff, 0xff, 0xff]; + let mut reader = Reader::new(&tag_bytes[..], 5); + match reader.read_tag() { + Err(crate::error::Error::SwfParseError { .. }) => (), + result => { + panic!("Expected SwfParseError, got {:?}", result); + } + } + } }