Skip to content

Commit ce69a6c

Browse files
committed
fix hidden bug when binding std::string and std::wstring. i have made a mistake reading the documentation. SQLITE_TRANSIENT should be used when the memory holding the string is temporary.(found it when testing on gcc 4.8)
1 parent 85330c0 commit ce69a6c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Diff for: sqlite_modern_cpp.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -134,13 +134,13 @@ namespace sqlite {
134134
return *this;
135135
}
136136
database_binder& operator <<(std::string const& txt) {
137-
if( sqlite3_bind_text( _stmt, _inx, txt.data(), -1, SQLITE_STATIC ) != SQLITE_OK )
137+
if( sqlite3_bind_text( _stmt, _inx, txt.data(), -1, SQLITE_TRANSIENT ) != SQLITE_OK )
138138
throw std::runtime_error( sqlite3_errmsg( _db ) );
139139
++_inx;
140140
return *this;
141141
}
142142
database_binder& operator <<(std::wstring const& txt) {
143-
if( sqlite3_bind_text16( _stmt, _inx, txt.data(), -1, SQLITE_STATIC ) != SQLITE_OK )
143+
if( sqlite3_bind_text16( _stmt, _inx, txt.data(), -1, SQLITE_TRANSIENT ) != SQLITE_OK )
144144
throw std::runtime_error( sqlite3_errmsg( _db ) );
145145
++_inx;
146146
return *this;

0 commit comments

Comments
 (0)