Skip to content

raise Vips::Error if copy_memory fails - #443

Merged
jcupitt merged 1 commit into
libvips:masterfrom
VitaliiLazebnyi:fix-copy-memory-null
Oct 15, 2026
Merged

jcupitt merged 1 commit into
libvips:masterfrom
VitaliiLazebnyi:fix-copy-memory-null

Conversation

@VitaliiLazebnyi

Copy link
Copy Markdown
Contributor

Fixes #442

vips_image_copy_memory() returns NULL on error (e.g. a truncated image), and copy_memory wrapped it unchecked, so the next call on the result segfaulted the process, which can't be rescued. It now raises Vips::Error, like write_to_memory.

The new spec uses the truncated coffee.gif sample from #419 and fails without the fix.

vips_image_copy_memory() returns NULL on error, for example when the
source cannot be decoded. copy_memory wrapped that pointer without a
check, so the next call on the returned image segfaulted.

Fixes libvips#442
@jcupitt

jcupitt commented Oct 15, 2026

Copy link
Copy Markdown
Member

Hi @VitaliiLazebnyi,

That's a silly oversight. Thanks for this PR!

@jcupitt
jcupitt merged commit cf89448 into libvips:master Oct 15, 2026
11 checks passed
@VitaliiLazebnyi

Copy link
Copy Markdown
Contributor Author

Thank you for the quick merge!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Image#copy_memory returns an image wrapping NULL when libvips fails, and the next call segfaults

2 participants