fogleman/Craft

Potential memory leak.

rachyyyy opened this issue · 3 comments

Potential memory leak in shell.c line 2357. The while loop is executed without releasing Zsql will cause a memory leak. Doc says "The sqlite3_mprintf() and sqlite3_vmprintf() routines write their results into memory obtained from sqlite3_malloc64(). The strings returned by these two routines should be released by sqlite3_free()." Using sqlite3_free() to free zSql will prevent the memory leak.

1662191655452

zSql is freed in line 2375

zSql is freed in line 2375

For all the mprintf() called in while loop (line 2357 and line 2364), the zSql should be freed after the while loop and before line 2373. Otherwise, there will be a potential memory leak.

You're right, my bad. This is also in contrast with what is seen throughout the rest of the file- were every pointer returned by mprintf() is indeed eventually freed. Of course, except the ones in this issue.