db: fix possible SQLite3 allocated memory leak in db_open()
From https://sqlite.org/c3ref/exec.html: To avoid memory leaks, the application should invoke sqlite3_free() on error message strings returned through the 5th parameter of sqlite3_exec() after the error message string is no longer needed. If the 5th parameter to sqlite3_exec() is not NULL and no errors occur, then sqlite3_exec() sets the pointer in its 5th parameter to NULL before returning. Change-Id: Ic9ed9bad3165bc4a637fe963f51e923f012e19ac Fixes: CID#208182
This commit is contained in:
parent
74e7072f63
commit
15ad7bef5f
4
src/db.c
4
src/db.c
|
@ -535,9 +535,11 @@ struct db_context *db_open(void *ctx, const char *fname, bool enable_sqlite_logg
|
|||
|
||||
char *err_msg;
|
||||
rc = sqlite3_exec(dbc->db, "PRAGMA journal_mode=WAL; PRAGMA synchonous = NORMAL;", 0, 0, &err_msg);
|
||||
if (rc != SQLITE_OK)
|
||||
if (rc != SQLITE_OK) {
|
||||
LOGP(DDB, LOGL_ERROR, "Unable to set Write-Ahead Logging: %s\n",
|
||||
err_msg);
|
||||
sqlite3_free(err_msg);
|
||||
}
|
||||
|
||||
version = db_get_user_version(dbc);
|
||||
if (version < 0) {
|
||||
|
|
Loading…
Reference in New Issue