Skip to content

Commit

Permalink
fix(h2non#159): prevent buf to be freed by the GC before resize funct…
Browse files Browse the repository at this point in the history
…ion exits
  • Loading branch information
h2non committed Aug 3, 2017
1 parent 14ff7ff commit 98c931e
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ bin
/*.webp
/fixtures/*_out.*
/.idea/
fixtures/test_vertical_*.jpg
Binary file modified fixtures/test_gif.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified fixtures/test_pdf.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified fixtures/test_svg.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion resize.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 98c931e

Please sign in to comment.