So I wrote myself a little wrapper function to make a prepared statement for me:
sqlite3_stmt* Gladiateur::run_query_unfinalized(string query, vector
Gladiateur::run_query_unfinalized(string query, vector<string> inputs)
The vector<string> inputs
is a copy, and it ceases to exist when the function returns.
Perhaps you should change it to:
Gladiateur::run_query_unfinalized(const string& query, const vector<string>& inputs)
With a reference, the c_str
should survive to do what you want to get done.
The last parameter of the sqlite3_bind_text function cannot be NULL:
The fifth argument to the BLOB and string binding interfaces is a destructor used to dispose of the BLOB or string after SQLite has finished with it. The destructor is called to dispose of the BLOB or string even if the call to bind API fails. If the fifth argument is the special value SQLITE_STATIC, then SQLite assumes that the information is in static, unmanaged space and does not need to be freed. If the fifth argument has the value SQLITE_TRANSIENT, then SQLite makes its own private copy of the data immediately, before the sqlite3_bind_*() routine returns.
In this case, you need SQLITE_TRANSIENT
.