go-sqlite3 icon indicating copy to clipboard operation
go-sqlite3 copied to clipboard

Fix memory leak in callbackRetText function

Open hionay opened this issue 1 year ago • 2 comments

This PR fixes the memory leak in the callbackRetText function by freeing the memory allocated by the code:

C.CString(v.Interface().(string))

hionay avatar Jul 12 '24 14:07 hionay

Real LLM vibes with that last review comment.

otoolep avatar Jul 13 '24 16:07 otoolep

Hi @mattn, how can I help in getting this merged?

hionay avatar Jul 14 '24 18:07 hionay

@mattn / @rittneje this is a pretty straightforward (and correct) fix for an obvious bug - could either of you take a look at this PR?

charlievieth avatar Dec 08 '24 07:12 charlievieth

@mattn Have you had a chance to look at this PR?

hionay avatar Apr 01 '25 11:04 hionay

thank you. please wait

mattn avatar Apr 01 '25 13:04 mattn

Thank you

mattn avatar Apr 01 '25 13:04 mattn

I revert this PR. This break original behavior.

mattn avatar Apr 02 '25 16:04 mattn

Original code have no problem.

mattn avatar Apr 02 '25 16:04 mattn

void _sqlite3_result_text(sqlite3_context* ctx, const char* s) {
  sqlite3_result_text(ctx, s, -1, &free);
}

This s is free-ed correctly.

mattn avatar Apr 02 '25 16:04 mattn