ruby-vips
ruby-vips copied to clipboard
FFI::NullPointerError: when reading the smallest GIF
Vips::Image.new_from_buffer("GIF89a\x01\x00\x01\x00\x00\xff\x00,\x00\x00\x00\x00\x01\x00\x01\x00\x00\x02\x00;", "").to_enum
FFI::NullPointerError: invalid memory read at address=0x0000000000000000
MacOS, ruby 2.3.8, ruby-vips-2.1.4, vips-8.11.3
I suppose I took it from here http://probablyprogramming.com/2009/03/15/the-tiniest-gif-ever
Hi @Nakilon,
Ouch, that's bad, thanks for the report. It seems to be fixed in master and in 8.13:
$ irb
irb(main):001:0> require 'vips'
=> true
irb(main):002:0> Vips::Image.new_from_buffer("GIF89a\x01\x00\x01\x00\x00\xff\x00,\x00\x00\x00\x00\x01\x00\x01\x00\x00\x02\x00;", "")
=> #<Image 1x1 uchar, 3 bands, srgb>
irb(main):003:0>
Oh, good to know. Indeed I see lots of recent GIF-related commits. Fine then. I used a bit larger file from the same article for my unit test for now.
Ah, I remembered having seeing this before with the old giflib-based loader, see e.g. https://github.com/libvips/libvips/issues/773.
I think(?) commit https://github.com/netsurf-browser/libnsgif/commit/41f33c7495e7b83b40a93e4a76481d770f0c5f7b fixed this. This was landed in libvips with commit https://github.com/libvips/libvips/commit/8c9d899acd06adda710149b242a1f57a096e530e.