mirror of
https://github.com/talgo-cloud/bimg.git
synced 2026-03-14 18:05:55 -07:00
fix(#159): prevent buf to be freed by the GC before resize function exits
This commit is contained in:
parent
14ff7ff2c8
commit
98c931eb89
5 changed files with 3 additions and 1 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -6,3 +6,4 @@ bin
|
||||||
/*.webp
|
/*.webp
|
||||||
/fixtures/*_out.*
|
/fixtures/*_out.*
|
||||||
/.idea/
|
/.idea/
|
||||||
|
fixtures/test_vertical_*.jpg
|
||||||
|
|
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 0 B After Width: | Height: | Size: 111 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 0 B After Width: | Height: | Size: 64 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 0 B After Width: | Height: | Size: 116 KiB |
|
|
@ -9,15 +9,16 @@ import "C"
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"math"
|
"math"
|
||||||
|
"runtime"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Resize is used to transform a given image as byte buffer
|
// Resize is used to transform a given image as byte buffer
|
||||||
// with the passed options.
|
// with the passed options.
|
||||||
func Resize(buf []byte, o Options) ([]byte, error) {
|
func Resize(buf []byte, o Options) ([]byte, error) {
|
||||||
defer C.vips_thread_shutdown()
|
defer C.vips_thread_shutdown()
|
||||||
|
defer runtime.KeepAlive(buf)
|
||||||
|
|
||||||
image, imageType, err := loadImage(buf)
|
image, imageType, err := loadImage(buf)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue