vips
vips copied to clipboard
Bindings will hard crash on invalid color space
The attached patch addresses this crash, which happens with specific ill-formed jpegs.
diff --git a/vips.go b/vips.go
index 36118e1..14cd90a 100644
--- a/vips.go
+++ b/vips.go
@@ -311,6 +311,10 @@ func Resize(buf []byte, o Options) ([]byte, error) {
C.vips_colourspace_0(image, &tmpImage, C.VIPS_INTERPRETATION_sRGB)
C.g_object_unref(C.gpointer(image))
image = tmpImage
+ if image == nil {
+ debug("colourspace conversion failed")
+ return nil, resizeError()
+ }
// Finally save
length := C.size_t(0)
Thank you! I'll apply the patch asap.
I think it would probably be safer to test the exit status of vips_colourspace(). It will return 0 for success, -1 for failure.
Thanks @jcupitt
Will this be patched? I seem to have hit the same problem.