int rc;
if (sqlite3_exec(m_pDB, query.c_str(), NULL, NULL, &errmsg) == SQLITE_BUSY) {
if (m_in_transaction) {
- throw("Failed to execute query: " + string(errmsg));
+ std::string errstr(errmsg);
+ sqlite3_free(errmsg);
+ throw("Failed to execute query: " + errstr);
} else {
- if ((rc = sqlite3_exec(m_pDB, query.c_str(), NULL, NULL, &errmsg) != SQLITE_OK) && rc != SQLITE_DONE && rc != SQLITE_ROW)
- throw("Failed to execute query: " + string(errmsg));
+ if ((rc = sqlite3_exec(m_pDB, query.c_str(), NULL, NULL, &errmsg) != SQLITE_OK) && rc != SQLITE_DONE && rc != SQLITE_ROW) {
+ std::string errstr(errmsg);
+ sqlite3_free(errmsg);
+ throw("Failed to execute query: " + errstr);
+ }
}
}
}