File tree Expand file tree Collapse file tree 1 file changed +9
-6
lines changed
cocos/scripting/lua-bindings/manual/network Expand file tree Collapse file tree 1 file changed +9
-6
lines changed Original file line number Diff line number Diff line change @@ -266,15 +266,18 @@ void LuaMinXmlHttpRequest::_setHttpRequestHeader()
266266 const char * second = it->second .c_str ();
267267 size_t len = sizeof (char ) * (strlen (first) + 3 + strlen (second));
268268 char * test = (char *) malloc (len);
269- memset (test, 0 ,len);
269+ if (test != nullptr ) // should check failure of malloc or it could be an undefined behaviour
270+ {
271+ memset (test, 0 ,len);
270272
271- strcpy (test, first);
272- strcpy (test + strlen (first) , " : " );
273- strcpy (test + strlen (first) + 2 , second);
273+ strcpy (test, first);
274+ strcpy (test + strlen (first) , " : " );
275+ strcpy (test + strlen (first) + 2 , second);
274276
275- header.push_back (test);
277+ header.push_back (test);
276278
277- free (test);
279+ free (test);
280+ }
278281
279282 }
280283
You can’t perform that action at this time.
0 commit comments