From d9168d5b447193d865f043d080101874d3c33b64 Mon Sep 17 00:00:00 2001 From: Halil ibrahim Onay Date: Fri, 12 Jul 2024 17:14:15 +0300 Subject: [PATCH] chore: Fix memory leak in callbackRetText function --- callback.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/callback.go b/callback.go index b794bcd..84612b4 100644 --- a/callback.go +++ b/callback.go @@ -345,7 +345,9 @@ func callbackRetText(ctx *C.sqlite3_context, v reflect.Value) error { if v.Type().Kind() != reflect.String { 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 }