Skip to content

Bindings will hard crash on invalid color space  #24

@dave-andersen

Description

@dave-andersen

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions