New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

`readlong': undefined method `unpack' for nil:NilClass (NoMethodError) #20

Closed
kyanny opened this Issue Jul 21, 2011 · 1 comment

Comments

2 participants
@kyanny

kyanny commented Jul 21, 2011

EXIFR::TIFF::Data#readlong throws exception for this image file.

http://dl.dropbox.com/u/4289117/2011-01-02%2016.24.57%5B1%5D.jpg

This photo was taken by Galaxy S camera in consinuous shooting mode.

backtrace is below.

$ exifr ~/daniel.jpg 
/usr/lib64/ruby/gems/1.8/gems/exifr-1.0.5/lib/exifr/tiff.rb:573:in `readlong': undefined method `unpack' for nil:NilClass (NoMethodError)
        from /usr/lib64/ruby/gems/1.8/gems/exifr-1.0.5/lib/exifr/tiff.rb:460:in `initialize'
        from /usr/lib64/ruby/gems/1.8/gems/exifr-1.0.5/lib/exifr/tiff.rb:399:in `new'
        from /usr/lib64/ruby/gems/1.8/gems/exifr-1.0.5/lib/exifr/tiff.rb:399:in `initialize'
        from /usr/lib64/ruby/gems/1.8/gems/exifr-1.0.5/lib/exifr/tiff.rb:398:in `times'
        from /usr/lib64/ruby/gems/1.8/gems/exifr-1.0.5/lib/exifr/tiff.rb:398:in `initialize'
        from /usr/lib64/ruby/gems/1.8/gems/exifr-1.0.5/lib/exifr/tiff.rb:448:in `new'
        from /usr/lib64/ruby/gems/1.8/gems/exifr-1.0.5/lib/exifr/tiff.rb:448:in `add_field'
        from /usr/lib64/ruby/gems/1.8/gems/exifr-1.0.5/lib/exifr/tiff.rb:399:in `initialize'
         ... 14 levels...
        from /usr/lib64/ruby/gems/1.8/gems/exifr-1.0.5/bin/exifr:50:in `each'
        from /usr/lib64/ruby/gems/1.8/gems/exifr-1.0.5/bin/exifr:50
        from /usr/bin/exifr:19:in `load'
        from /usr/bin/exifr:19

readlong (and also readshort) try to access data out of range.
self[pos..(pos + 3)] returns nil, so nil.unpack called and NoMethodError thrown.

https://github.com/remvee/exifr/blob/master/lib/exifr/tiff.rb#L572

In my case, I wrote wrapper method and catched all exception from readlong.

https://gist.github.com/1096796

I'm using rails, so I put these code in config/environment.rb.

my envrionment: ruby version 1.8.6, exifr version 1.0.5 (newest)

@kyanny

This comment has been minimized.

kyanny commented Aug 2, 2011

Very quick fix, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment