Fix 'getStr' to not crash on a non-existent column.

This commit is contained in:
JoelKatz
2013-04-25 09:09:04 -07:00
parent 93c4e5aa5f
commit 99e9bc0863

View File

@@ -179,8 +179,9 @@ bool SqliteDatabase::getNull(int colIndex)
char* SqliteDatabase::getStr(int colIndex,std::string& retStr) char* SqliteDatabase::getStr(int colIndex,std::string& retStr)
{ {
retStr=(char*)sqlite3_column_text(mCurrentStmt, colIndex); const char *text = reinterpret_cast<const char *>(sqlite3_column_text(mCurrentStmt, colIndex));
return((char*)retStr.c_str()); retStr = (text == NULL) ? "" : text;
return const_cast<char*>(retStr.c_str());
} }
int32 SqliteDatabase::getInt(int colIndex) int32 SqliteDatabase::getInt(int colIndex)