media file: fix exception when getting frame count of corrupted gif.

Fix a `gifload: no frames in GIF` error from libvips when trying to read
the frame count for https://danbooru.donmai.us/media_assets/1141668.
This commit is contained in:
evazion
2022-10-31 02:14:44 -05:00
parent 214a877c3c
commit dfd19f3ad4
3 changed files with 20 additions and 1 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

View File

@@ -471,6 +471,18 @@ class MediaFileTest < ActiveSupport::TestCase
assert_equal("89a", @metadata["GIF:GIFVersion"])
assert_equal(6, @metadata.count)
end
should "not raise an exception when reading the frame count" do
@file = MediaFile.open("test/files/gif/corrupt-static.gif")
@metadata = @file.metadata
assert_equal(true, @file.is_corrupt?)
assert_equal(nil, @file.frame_count)
assert_equal("File format error", @metadata["ExifTool:Error"])
assert_equal("89a", @metadata["GIF:GIFVersion"])
assert_equal(6, @metadata.count)
assert_nothing_raised { @file.attributes }
end
end
context "a corrupt PNG" do