[android] fix crash when point JNIEnv is a nullptr in getStringUTFCharsJNI func. (#19079)

This commit is contained in:
dingdekai 2018-09-29 13:58:06 +08:00 committed by leda
parent aca3016bee
commit ebc32043ea
1 changed files with 1 additions and 1 deletions

View File

@ -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);