xyb3rt / sxiv

Simple X Image Viewer
GNU General Public License v2.0
1.82k stars 261 forks source link

Thumbnail mode crashes with bad jpg imagedata: Cannot allocate memory #433

Open kristianlm opened 3 years ago

kristianlm commented 3 years ago

Hi,

I'm getting the same error as #325 so this may be a duplicate. I think I have managed to narrow things down to a image-metadata problem on a single jpg (attached below). I'm on Arch Linux. Here we go:

> sxiv -v
sxiv 26
> pacman -Qi sxiv | grep Version
Version         : 26-1
> pacman -Qi imlib2 | grep Version
Version         : 1.7.1-1
> sxiv bad.jpg
# [image shows up OK, but then I press enter]
sxiv: Cannot allocate memory
> ll
total 2.5M
-rw-r--r-- 1 klm klm 2.5M Jan 14 14:15 bad.jpg
> convert bad.jpg -resize 1% -quality 1% bad-small.jpg
> sxiv bad-small.jpg
# [same symptom: image shows up OK, but then I press enter]
sxiv: Cannot allocate memory
# trying now with the image metadata stripped off
> convert bad.jpg -strip -resize 1% -quality 1% bad-small-stripped.jpg
> ll
total 2.5M
-rw-r--r-- 1 klm klm 2.5M Jan 14 14:15 bad.jpg
-rw-r--r-- 1 klm klm  13K Jan 14 14:16 bad-small.jpg
-rw-r--r-- 1 klm klm  309 Jan 14 14:16 bad-small-stripped.jpg
> sxiv bad-small-stripped.jpg
# now things are working!
# examining bad-small.jpg with exiv2 shows a warning, perhaps this could be the sinner right there?
> exiv2 bad-small.jpg
Warning: Directory Thumbnail, entry 0x0201: Data area exceeds data buffer, ignoring it.
File name       : bad-small.jpg
File size       : 12597 Bytes
MIME type       : image/jpeg
Image size      : 26 x 19
Camera make     : Apple
Camera model    : iPhone 4
Image timestamp : 2015:11:01 14:52:35
Image number    : 
Exposure time   : 1/15 s
Aperture        : F2.8
Exposure bias   : 
Flash           : No, auto
Flash bias      : 
Focal length    : 3.8 mm (35 mm equivalent: 35.0 mm)
Subject distance: 
ISO speed       : 1000
Exposure mode   : Auto
Metering mode   : Multi-segment
Macro mode      : 
Image quality   : 
Exif Resolution : 2592 x 1936
White balance   : Auto
Thumbnail       : None
Copyright       : 
Exif comment    : 

# nobody was expecting anything here, but for completeness:
> exiv2 bad-small-stripped.jpg 
File name       : bad-small-stripped.jpg
File size       : 309 Bytes
MIME type       : image/jpeg
Image size      : 26 x 19
bad-small-stripped.jpg: No Exif data found in the file

This is the faulty image: bad-small

I hope you guys can get an unmodified copy back from github. It should look like this:

> sha1sum bad-small.jpg 
d1f2440a61ea8fb00003388464483f04b6a3e5ce  bad-small.jpg

Since #325 was closed, and possibly had a different cause, I though I'd create a new issue. Thanks for the sxiv suite!