summaryrefslogtreecommitdiff
path: root/vendor/gif/tests/crashtest.rs
diff options
context:
space:
mode:
authorValentin Popov <valentin@popov.link>2024-01-08 00:21:28 +0300
committerValentin Popov <valentin@popov.link>2024-01-08 00:21:28 +0300
commit1b6a04ca5504955c571d1c97504fb45ea0befee4 (patch)
tree7579f518b23313e8a9748a88ab6173d5e030b227 /vendor/gif/tests/crashtest.rs
parent5ecd8cf2cba827454317368b68571df0d13d7842 (diff)
downloadfparkan-1b6a04ca5504955c571d1c97504fb45ea0befee4.tar.xz
fparkan-1b6a04ca5504955c571d1c97504fb45ea0befee4.zip
Initial vendor packages
Signed-off-by: Valentin Popov <valentin@popov.link>
Diffstat (limited to 'vendor/gif/tests/crashtest.rs')
-rw-r--r--vendor/gif/tests/crashtest.rs28
1 files changed, 28 insertions, 0 deletions
diff --git a/vendor/gif/tests/crashtest.rs b/vendor/gif/tests/crashtest.rs
new file mode 100644
index 0000000..ef67cb3
--- /dev/null
+++ b/vendor/gif/tests/crashtest.rs
@@ -0,0 +1,28 @@
+use std::{fs, io};
+use gif::DecodeOptions;
+
+#[test]
+fn try_decode_crash_regression() {
+ let files = fs::read_dir(concat!(env!("CARGO_MANIFEST_DIR"), "/tests/crashtest")).unwrap();
+ let options = DecodeOptions::new();
+
+ for entry in files {
+ let entry = entry.unwrap();
+ if let Some(ext) = entry.path().extension() {
+ if ext.to_str() != Some("gif") {
+ panic!("Unexpected file {} in crashtests, should end with .gif", entry.path().display());
+ }
+ } else {
+ panic!("Unexpected file {} in crashtests, should end with .gif", entry.path().display());
+ }
+
+ let file_data = fs::read(entry.path()).unwrap();
+ let _ = try_decode_file(&options, file_data);
+ }
+}
+
+fn try_decode_file(options: &DecodeOptions, data: Vec<u8>) -> Result<(), gif::DecodingError> {
+ let mut reader = options.clone().read_info(io::Cursor::new(data))?;
+ while reader.read_next_frame()?.is_some() {}
+ Ok(())
+}