From e5d45583b7e1ac9c40ee4ebc12adc3b722568ba5 Mon Sep 17 00:00:00 2001 From: "Lee, Jae-Hong" Date: Wed, 22 Jan 2014 17:37:29 +0900 Subject: [PATCH] [Win32] fix localStorageGetItem crash when column text is NULL. --- cocos/storage/local-storage/LocalStorage.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/cocos/storage/local-storage/LocalStorage.cpp b/cocos/storage/local-storage/LocalStorage.cpp index b612c49a47..a3ca1c70ad 100644 --- a/cocos/storage/local-storage/LocalStorage.cpp +++ b/cocos/storage/local-storage/LocalStorage.cpp @@ -124,17 +124,19 @@ std::string localStorageGetItem( const std::string& key ) { assert( _initialized ); + std::string ret; int ok = sqlite3_reset(_stmt_select); ok |= sqlite3_bind_text(_stmt_select, 1, key.c_str(), -1, SQLITE_TRANSIENT); ok |= sqlite3_step(_stmt_select); - const unsigned char *ret = sqlite3_column_text(_stmt_select, 0); - + const unsigned char *text = sqlite3_column_text(_stmt_select, 0); + if (text) + ret = (const char*)text; if( ok != SQLITE_OK && ok != SQLITE_DONE && ok != SQLITE_ROW) printf("Error in localStorage.getItem()\n"); - return (const char*)ret; + return ret; } /** removes an item from the LS */