diff --git a/cocos/base/ccUTF8.cpp b/cocos/base/ccUTF8.cpp index c3d8c14945..b4714493f9 100644 --- a/cocos/base/ccUTF8.cpp +++ b/cocos/base/ccUTF8.cpp @@ -309,7 +309,7 @@ bool UTF32ToUTF16(const std::u32string& utf32, std::u16string& outUtf16) std::string getStringUTFCharsJNI(JNIEnv* env, jstring srcjStr, bool* ret) { std::string utf8Str; - if(srcjStr != nullptr) + if(srcjStr != nullptr && env != nullptr) { const unsigned short * unicodeChar = ( const unsigned short *)env->GetStringChars(srcjStr, nullptr); size_t unicodeCharLength = env->GetStringLength(srcjStr);