Skip to content

Commit 753d56d

Browse files
committed
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 <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Agniva De Sarker <[email protected]> Reviewed-by: Richard Musiol <[email protected]>
1 parent 866920a commit 753d56d

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/syscall/fs_js.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ func fsCall(name string, args ...interface{}) (js.Value, error) {
495495
}
496496

497497
c := make(chan callResult, 1)
498-
jsFS.Call(name, append(args, js.FuncOf(func(this js.Value, args []js.Value) interface{} {
498+
f := js.FuncOf(func(this js.Value, args []js.Value) interface{} {
499499
var res callResult
500500

501501
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) {
511511

512512
c <- res
513513
return nil
514-
}))...)
514+
})
515+
defer f.Release()
516+
jsFS.Call(name, append(args, f)...)
515517
res := <-c
516518
return res.val, res.err
517519
}

0 commit comments

Comments
 (0)