Take care to not dereference the original image a second time

master
Aarti Parikh 10 years ago
parent cb0afe5786
commit db78c9b75e

@ -318,7 +318,12 @@ func vipsSave(image *C.VipsImage, o vipsSaveOptions) ([]byte, error) {
if err != nil {
return nil, err
}
defer C.g_object_unref(C.gpointer(tmpImage))
//When an image has an unsupported color space, vipsPreSave returns the pointer of the image passed to it unmodified.
//When this occurs, we must take care to not dereference the original image a second time;
//we may otherwise erroneously free the object twice
if tmpImage != image {
defer C.g_object_unref(C.gpointer(tmpImage))
}
length := C.size_t(0)
saveErr := C.int(0)

Loading…
Cancel
Save