fix(#159): prevent buf to be freed by the GC before resize function exits

This commit is contained in:
Tomas Aparicio 2017-08-03 12:48:30 +02:00
parent 14ff7ff2c8
commit 98c931eb89
5 changed files with 3 additions and 1 deletions

View file

@ -9,15 +9,16 @@ import "C"
import (
"errors"
"math"
"runtime"
)
// Resize is used to transform a given image as byte buffer
// with the passed options.
func Resize(buf []byte, o Options) ([]byte, error) {
defer C.vips_thread_shutdown()
defer runtime.KeepAlive(buf)
image, imageType, err := loadImage(buf)
if err != nil {
return nil, err
}