Browse Source

Fixed an issue for SQLite queries where String::Trimmed was returning a corrupted version of the query string

Victor Holt 9 years ago
parent
commit
c486b1608b
1 changed files with 6 additions and 1 deletions
  1. 6 1
      Source/Urho3D/Database/SQLite/SQLiteConnection.cpp

+ 6 - 1
Source/Urho3D/Database/SQLite/SQLiteConnection.cpp

@@ -64,7 +64,12 @@ DbResult DbConnection::Execute(const String& sql, bool useCursorEvent)
     const char* zLeftover = 0;
     const char* zLeftover = 0;
     sqlite3_stmt* pStmt = 0;
     sqlite3_stmt* pStmt = 0;
     assert(connectionImpl_);
     assert(connectionImpl_);
-    int rc = sqlite3_prepare_v2(connectionImpl_, sql.Trimmed().CString(), -1, &pStmt, &zLeftover);
+
+    // 2016-10-09: Prevent string corruption when trimmed is returned.
+    String trimmedSqlStr = sql.Trimmed();
+    const char* cSqlStr = trimmedSqlStr.CString();
+
+    int rc = sqlite3_prepare_v2(connectionImpl_, cSqlStr, -1, &pStmt, &zLeftover);
     if (rc != SQLITE_OK)
     if (rc != SQLITE_OK)
     {
     {
         URHO3D_LOGERRORF("Could not execute: %s", sqlite3_errmsg(connectionImpl_));
         URHO3D_LOGERRORF("Could not execute: %s", sqlite3_errmsg(connectionImpl_));