diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2009-12-04 15:58:33 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2009-12-04 15:58:33 +0100 |
commit | 408b904db46c37c59ac2f40edd5fe42fd0cac1d2 (patch) | |
tree | 5e742a22a215d240b66d81edd848e18e0b59f9fd /lib/Plugins/SQLite3.cpp | |
parent | 8e5a812ce758321fb4f1ee4c181445db34ad39d8 (diff) | |
download | abrt-408b904db46c37c59ac2f40edd5fe42fd0cac1d2.tar.gz abrt-408b904db46c37c59ac2f40edd5fe42fd0cac1d2.tar.xz abrt-408b904db46c37c59ac2f40edd5fe42fd0cac1d2.zip |
SQLite3: fix leak on error path; log SQL cmd and results on -vv
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'lib/Plugins/SQLite3.cpp')
-rw-r--r-- | lib/Plugins/SQLite3.cpp | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/lib/Plugins/SQLite3.cpp b/lib/Plugins/SQLite3.cpp index 788d43be..866b9857 100644 --- a/lib/Plugins/SQLite3.cpp +++ b/lib/Plugins/SQLite3.cpp @@ -100,14 +100,16 @@ static void get_table(vector_database_rows_t& pTable, char **table; int ncol, nrow; - char *err; + char *err = NULL; int ret = sqlite3_get_table(db, sql, &table, &nrow, &ncol, &err); if (ret != SQLITE_OK) { string errstr = ssprintf("Error in SQL:'%s' error: %s", sql, err); free(sql); + sqlite3_free(err); throw CABRTException(EXCEP_PLUGIN, errstr); } + VERB2 log("%d rows returned by SQL:%s", nrow, sql); free(sql); pTable.clear(); @@ -143,14 +145,16 @@ static void execute_sql(sqlite3 *db, const char *fmt, ...) char *sql = xvasprintf(fmt, p); va_end(p); - char *err; - int ret = sqlite3_exec(db, sql, 0, 0, &err); + char *err = NULL; + int ret = sqlite3_exec(db, sql, /*callback:*/ NULL, /*callback param:*/ NULL, &err); if (ret != SQLITE_OK) { string errstr = ssprintf("Error in SQL:'%s' error: %s", sql, err); free(sql); + sqlite3_free(err); throw CABRTException(EXCEP_PLUGIN, errstr); } + VERB2 log("%d rows affected by SQL:%s", sqlite3_changes(db), sql); free(sql); } @@ -184,7 +188,7 @@ static bool check_table(sqlite3 *db) /* Should never happen */ error_msg_and_die("SQLite3 database is corrupted"); } - if (!nrow || !nrow) + if (!nrow) { return false; } @@ -201,7 +205,7 @@ static bool check_table(sqlite3 *db) return true; } - // TODO: after some time could be removed, and if a table is that old, + // TODO: after some time could be removed, and if the table is that old, // then simply drop it and create new one // hack for version 0 and 1 |