chore: Fix memory leak in callbackRetText function

This commit is contained in:
Halil ibrahim Onay 2024-07-12 17:14:15 +03:00
parent 3c0390b77c
commit d9168d5b44
1 changed files with 3 additions and 1 deletions

View File

@ -345,7 +345,9 @@ func callbackRetText(ctx *C.sqlite3_context, v reflect.Value) error {
if v.Type().Kind() != reflect.String { if v.Type().Kind() != reflect.String {
return fmt.Errorf("cannot convert %s to TEXT", v.Type()) return fmt.Errorf("cannot convert %s to TEXT", v.Type())
} }
C._sqlite3_result_text(ctx, C.CString(v.Interface().(string))) cstr := C.CString(v.Interface().(string))
defer C.free(unsafe.Pointer(cstr))
C._sqlite3_result_text(ctx, cstr)
return nil return nil
} }