Let's call sqlite3_finalize() on stmt so resources are freed and we
don't leak it:
==11116== 107,752 (856 direct, 106,896 indirect) bytes in 1 blocks are definitely lost in loss record 84 of 84
==11116== at 0x4C2757B: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==11116== by 0x5076816: ??? (in /usr/lib/libsqlite3.so.0.8.6)
==11116== by 0x5052889: ??? (in /usr/lib/libsqlite3.so.0.8.6)
==11116== by 0x505A6C7: ??? (in /usr/lib/libsqlite3.so.0.8.6)
==11116== by 0x505A6EC: ??? (in /usr/lib/libsqlite3.so.0.8.6)
==11116== by 0x50D27F0: ??? (in /usr/lib/libsqlite3.so.0.8.6)
==11116== by 0x401F22: show (test.c:377)
==11116== by 0x401913: main (test.c:481)
char path[PATH_MAX];
const char *db_path;
sqlite3 *db;
- sqlite3_stmt *stmt;
+ sqlite3_stmt *stmt = NULL;
int r, len;
if (!realpath(orig_path, path)) {
r = 0;
}
- sqlite3_reset(stmt);
- sqlite3_clear_bindings(stmt);
- close_and_exit:
+close_and_exit:
+ if (stmt)
+ sqlite3_finalize(stmt);
sqlite3_close(db);
return r;