I use SQLCipher to store encrypted SQLite . However, when I use sqlite3_key to encrypt the database, I start getting a memory leak. Observe the following example:
#include <sqlite3.h> int main() { sqlite3 * connection; sqlite3_open_v2(":memory:", &connection, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, NULL); sqlite3_key(connection, "passphrase", 10); sqlite3_close(connection); }
This pattern creates a memory leak. If I delete the sqlite3_key call, the memory leak will disappear.
I narrowed down some possible culprits:
- Although the sample uses a database in memory (hence
":memory:" ), I see the same result when using file databases. - All return codes from
sqlite3_* SQLITE_OK , which means there are no errors. - Buffer length
10 for "passphrase" not a problem.
However, no matter how many connections I create or how many different encryption keys I use, the memory leak is always around 8 kilobytes. This makes me suspect that this is actually not a memory leak, but only some persistent global memory in SQLite / SQLCipher, which is not manually freed.
Has anyone experienced this before? Is there any way to get rid of the leak? Even if this is not an official memory leak, it is difficult to detect real memory leaks with this real one.
I am using the SQLCipher library for Windows .
source share