cocos / engine-native

Native engine for Cocos Creator v2.x

Home Page:http://www.cocos.com/en/products

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

strdup 会在某些64位android手机造成 segfault

dunadain opened this issue · comments

请将httpclient-java.cpp中 getBufferFromJString函数改成,不要使用strdup
char *getBufferFromJString(jstring jstr, JNIEnv *env) { //NOLINT(readability-convert-member-functions-to-static)
if (nullptr == jstr) {
return nullptr;
}
std::string strValue = cc::StringUtils::getStringUTFCharsJNI(env, jstr);
auto size = strlen(strValue.c_str());
char c = (char)malloc(size + 1);
strcpy(c, strValue.c_str());
return c;
}

strdup 具体指的是?