mirror of
https://github.com/talgo-cloud/bimg.git
synced 2026-03-15 10:25:55 -07:00
Take care to not dereference the original image a second time
This commit is contained in:
parent
cb0afe5786
commit
db78c9b75e
1 changed files with 6 additions and 1 deletions
7
vips.go
7
vips.go
|
|
@ -318,7 +318,12 @@ func vipsSave(image *C.VipsImage, o vipsSaveOptions) ([]byte, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
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)
|
length := C.size_t(0)
|
||||||
saveErr := C.int(0)
|
saveErr := C.int(0)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue