Skip to content
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

Bindings will hard crash on invalid color space #24

Open
dave-andersen opened this issue May 30, 2015 · 4 comments
Open

Bindings will hard crash on invalid color space #24

dave-andersen opened this issue May 30, 2015 · 4 comments

Comments

@dave-andersen
Copy link

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)
@DAddYE
Copy link
Owner

DAddYE commented Jun 1, 2015

Thank you! I'll apply the patch asap.

@jcupitt
Copy link

jcupitt commented Jun 7, 2015

I think it would probably be safer to test the exit status of vips_colourspace(). It will return 0 for success, -1 for failure.

@DAddYE
Copy link
Owner

DAddYE commented Jun 8, 2015

Thanks @jcupitt

@eriken
Copy link

eriken commented Feb 19, 2016

Will this be patched? I seem to have hit the same problem.

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

No branches or pull requests

4 participants