Skip to content

Commit dab59b8

Browse files
committed
Fix issue #109
The temporary return value of method wxString::utf8_str(), representing the cipher name, was destroyed, before it could be used to configure the cipher scheme. The value is now assigned to a local variable, first.
1 parent 4f2be04 commit dab59b8

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

src/wxsqlite3.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5725,7 +5725,8 @@ wxSQLite3Cipher::GetCipherType(const wxString& cipherName)
57255725
bool
57265726
wxSQLite3Cipher::SetCipher(wxSQLite3Database& db, wxSQLite3CipherType cipherType)
57275727
{
5728-
const char* cipherName = GetCipherName(cipherType).utf8_str();
5728+
wxCharBuffer strCipherName = GetCipherName(cipherType).utf8_str();
5729+
const char* cipherName = strCipherName;
57295730
sqlite3* dbHandle = (sqlite3*) GetDatabaseHandle(db);
57305731
int newCipherType = (dbHandle != NULL) ? sqlite3mc_config(dbHandle, "cipher", sqlite3mc_cipher_index(cipherName)) : WXSQLITE_CIPHER_UNKNOWN;
57315732
return (newCipherType > 0 && newCipherType == (int) cipherType && newCipherType != WXSQLITE_CIPHER_UNKNOWN);
@@ -5734,7 +5735,8 @@ wxSQLite3Cipher::SetCipher(wxSQLite3Database& db, wxSQLite3CipherType cipherType
57345735
bool
57355736
wxSQLite3Cipher::SetCipherDefault(wxSQLite3Database& db, wxSQLite3CipherType cipherType)
57365737
{
5737-
const char* cipherName = GetCipherName(cipherType).utf8_str();
5738+
wxCharBuffer strCipherName = GetCipherName(cipherType).utf8_str();
5739+
const char* cipherName = strCipherName;
57385740
sqlite3* dbHandle = (sqlite3*) GetDatabaseHandle(db);
57395741
int newCipherType = (dbHandle != NULL) ? sqlite3mc_config(dbHandle, "default:cipher", sqlite3mc_cipher_index(cipherName)) : WXSQLITE_CIPHER_UNKNOWN;
57405742
return (newCipherType > 0 && newCipherType == (int) cipherType && newCipherType != WXSQLITE_CIPHER_UNKNOWN);

0 commit comments

Comments
 (0)