Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Potential memory leak. #299

Open
rachyyyy opened this issue Sep 3, 2022 · 3 comments
Open

Potential memory leak. #299

rachyyyy opened this issue Sep 3, 2022 · 3 comments

Comments

@rachyyyy
Copy link

rachyyyy commented Sep 3, 2022

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

@OctavioAnino
Copy link

zSql is freed in line 2375

@rachyyyy
Copy link
Author

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.

@OctavioAnino
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants