sqlite icon indicating copy to clipboard operation
sqlite copied to clipboard

Potential memory leak with sqlite3_expanded_sql?

Open burdiyan opened this issue 3 years ago • 0 comments

According to the docs strings returned by sqlite3_expanded_sql should be freed manually with sqlite3_free:

https://www.sqlite.org/c3ref/expanded_sql.html

The string returned by sqlite3_expanded_sql(P), on the other hand, is obtained from sqlite3_malloc() and must be freed by the application by passing it to sqlite3_free().

Here the C value is passed directly to C.GoString. I'm not an expert in CGO and I don't know if this could be a potential memory leak.

https://github.com/tailscale/sqlite/blob/f1ddf613ed756f0bb15510a44936a745d2aee3cf/cgosqlite/cgosqlite.go#L189

burdiyan avatar Dec 21 '21 21:12 burdiyan