diff --git a/cocos/scripting/lua-bindings/manual/network/lua_xml_http_request.cpp b/cocos/scripting/lua-bindings/manual/network/lua_xml_http_request.cpp index f1b1b71dc7..c15bfdfc1a 100644 --- a/cocos/scripting/lua-bindings/manual/network/lua_xml_http_request.cpp +++ b/cocos/scripting/lua-bindings/manual/network/lua_xml_http_request.cpp @@ -262,23 +262,7 @@ void LuaMinXmlHttpRequest::_setHttpRequestHeader() for (auto it = _requestHeader.begin(); it != _requestHeader.end(); ++it) { - const char* first = it->first.c_str(); - const char* second = it->second.c_str(); - size_t len = sizeof(char) * (strlen(first) + 3 + strlen(second)); - char* test = (char*) malloc(len); - if (test != nullptr) //should check failure of malloc or it could be an undefined behaviour - { - memset(test, 0,len); - - strcpy(test, first); - strcpy(test + strlen(first) , ": "); - strcpy(test + strlen(first) + 2, second); - - header.push_back(test); - - free(test); - } - + header.push_back(it->first + ": " + it->second); } if (!header.empty())