Fixes infinite loop with certain jpegs, adds test. Fixes #19.

This commit is contained in:
Stephen Sykes 2013-09-17 18:25:47 +03:00
parent 6913762c93
commit 63b97f7ef0
3 changed files with 5 additions and 3 deletions

View File

@ -445,8 +445,9 @@ class FastImage
end
next_offset = get_chars(4).unpack(@long)[0]
if next_offset > 0
get_chars(next_offset - (@bytes_delivered - @exif_start_byte))
relative_offset = next_offset - (@bytes_delivered - @exif_start_byte)
if relative_offset >= 0
get_chars(relative_offset)
parse_exif_ifd
end
end

BIN
test/fixtures/infinite.jpg vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

View File

@ -19,7 +19,8 @@ GoodFixtures = {
"test3.jpg"=>[:jpeg, [630, 367]],
"test.tiff"=>[:tiff, [85, 67]],
"test2.tiff"=>[:tiff, [333, 225]],
"exif_orientation.jpg"=>[:jpeg, [2448, 3264]]
"exif_orientation.jpg"=>[:jpeg, [2448, 3264]],
"infinite.jpg"=>[:jpeg, [160,240]]
}
BadFixtures = [