Skip to content

Commit 5095abd

Browse files
committed
fix: Do not close wazero module on error (#3758)
wazero takes care not to leak modules when `InstantiateModule` returns an error. This means that sqlc will call `result.Close` a second time if a non nil module was returned, which causes a segfault.
1 parent 7700b5a commit 5095abd

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

internal/ext/wasm/wasm.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ func (r *Runner) Invoke(ctx context.Context, method string, args any, reply any,
222222
}
223223

224224
result, err := runtimeAndCode.rt.InstantiateModule(ctx, runtimeAndCode.code, conf)
225-
if result != nil {
225+
if err == nil {
226226
defer result.Close(ctx)
227227
}
228228
if cerr := checkError(err, stderr); cerr != nil {

0 commit comments

Comments
 (0)