]> git.ipfire.org Git - thirdparty/pdns.git/blobdiff - pdns/ssqlite3.cc
Merge pull request #8223 from PowerDNS/omoerbeek-patch-1
[thirdparty/pdns.git] / pdns / ssqlite3.cc
index 752c72950b18779e5bbfc5c6ab4e00e8fdc7097d..507f2cd2353973e40bbe7250bae9c12870570bc3 100644 (file)
@@ -235,10 +235,15 @@ void SSQLite3::execute(const string& query) {
   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);
+      }
     }
   }
 }