syscall: release a js.Func object in fsCall

A js.Func object in fsCall was created for each call but never
released. This CL fixes this.

Change-Id: I2e2b504cbf4fb130b8cfe890a66d3a66aadf56a4
Reviewed-on: https://go-review.googlesource.com/c/go/+/217417
Run-TryBot: Hajime Hoshi <hajimehoshi@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Agniva De Sarker <agniva.quicksilver@gmail.com>
Reviewed-by: Richard Musiol <neelance@gmail.com>
This commit is contained in:
Hajime Hoshi 2020-02-02 14:55:29 +09:00
parent 866920a073
commit 753d56d364
1 changed files with 4 additions and 2 deletions

View File

@ -495,7 +495,7 @@ func fsCall(name string, args ...interface{}) (js.Value, error) {
}
c := make(chan callResult, 1)
jsFS.Call(name, append(args, js.FuncOf(func(this js.Value, args []js.Value) interface{} {
f := js.FuncOf(func(this js.Value, args []js.Value) interface{} {
var res callResult
if len(args) >= 1 { // on Node.js 8, fs.utimes calls the callback without any arguments
@ -511,7 +511,9 @@ func fsCall(name string, args ...interface{}) (js.Value, error) {
c <- res
return nil
}))...)
})
defer f.Release()
jsFS.Call(name, append(args, f)...)
res := <-c
return res.val, res.err
}