Skip to content

Commit

Permalink
Fix issue #109
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
utelle committed Mar 1, 2023
1 parent 4f2be04 commit dab59b8
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/wxsqlite3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5725,7 +5725,8 @@ wxSQLite3Cipher::GetCipherType(const wxString& cipherName)
bool
wxSQLite3Cipher::SetCipher(wxSQLite3Database& db, wxSQLite3CipherType cipherType)
{
const char* cipherName = GetCipherName(cipherType).utf8_str();
wxCharBuffer strCipherName = GetCipherName(cipherType).utf8_str();
const char* cipherName = strCipherName;
sqlite3* dbHandle = (sqlite3*) GetDatabaseHandle(db);
int newCipherType = (dbHandle != NULL) ? sqlite3mc_config(dbHandle, "cipher", sqlite3mc_cipher_index(cipherName)) : WXSQLITE_CIPHER_UNKNOWN;
return (newCipherType > 0 && newCipherType == (int) cipherType && newCipherType != WXSQLITE_CIPHER_UNKNOWN);
Expand All @@ -5734,7 +5735,8 @@ wxSQLite3Cipher::SetCipher(wxSQLite3Database& db, wxSQLite3CipherType cipherType
bool
wxSQLite3Cipher::SetCipherDefault(wxSQLite3Database& db, wxSQLite3CipherType cipherType)
{
const char* cipherName = GetCipherName(cipherType).utf8_str();
wxCharBuffer strCipherName = GetCipherName(cipherType).utf8_str();
const char* cipherName = strCipherName;
sqlite3* dbHandle = (sqlite3*) GetDatabaseHandle(db);
int newCipherType = (dbHandle != NULL) ? sqlite3mc_config(dbHandle, "default:cipher", sqlite3mc_cipher_index(cipherName)) : WXSQLITE_CIPHER_UNKNOWN;
return (newCipherType > 0 && newCipherType == (int) cipherType && newCipherType != WXSQLITE_CIPHER_UNKNOWN);
Expand Down

0 comments on commit dab59b8

Please sign in to comment.