Skip to content

FFI::NullPointerError raised in write_to_memory on invalid image data #419

@dloebl

Description

@dloebl

image.write_to_memory sometimes raises a FFI::NullPointerError if the image has invalid image data.

To Reproduce
Steps to reproduce the behavior:
coffee-19613_128.gif

null_pointer_error.rb:

require "vips"

img = Vips::Image.new_from_file "coffee-19613_128.gif"
img.write_to_memory
$ ruby null_pointer_error.rb

(process:32892): VIPS-WARNING **: 11:54:17.971: Unexpected end of GIF source data

(process:32892): VIPS-WARNING **: 11:54:17.972: error in tile 0 x 0
ruby-vips-2.2.3/lib/vips/image.rb:708:in 'FFI::AbstractMemory#get_bytes': invalid memory read at address=0x0000000000000000 (FFI::NullPointerError)
	from ruby-vips-2.2.3/lib/vips/image.rb:708:in 'Vips::Image#write_to_memory'
	from null_pointer_error.rb:4:in '<main>

Expected behavior
Vips::Error raised instead

ruby-vips version: v2.2.3
libvips version: v8.16.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions