Skip to content

Commit b9f4d8c

Browse files
hionaymattn
authored andcommitted
chore: Fix memory leak in callbackRetText function
1 parent 7658c06 commit b9f4d8c

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

callback.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,9 @@ func callbackRetText(ctx *C.sqlite3_context, v reflect.Value) error {
345345
if v.Type().Kind() != reflect.String {
346346
return fmt.Errorf("cannot convert %s to TEXT", v.Type())
347347
}
348-
C._sqlite3_result_text(ctx, C.CString(v.Interface().(string)))
348+
cstr := C.CString(v.Interface().(string))
349+
defer C.free(unsafe.Pointer(cstr))
350+
C._sqlite3_result_text(ctx, cstr)
349351
return nil
350352
}
351353

0 commit comments

Comments
 (0)