Processing Lua file(UTF8+BOM) that is encrypted will crash,when free the buffer pointer that is changed pointer address. (#17937)

This commit is contained in:
Y-way 2017-06-20 09:02:40 +08:00 committed by minggo
parent 3e912ffee3
commit e6210874dd
1 changed files with 4 additions and 2 deletions

View File

@ -874,8 +874,10 @@ int LuaStack::luaLoadBuffer(lua_State *L, const char *chunk, int chunkSize, cons
(unsigned char*)_xxteaKey, (unsigned char*)_xxteaKey,
(xxtea_long)_xxteaKeyLen, (xxtea_long)_xxteaKeyLen,
&len); &len);
skipBOM((const char*&)result, (int&)len); unsigned char* content = result;
r = luaL_loadbuffer(L, (char*)result, len, chunkName); xxtea_long contentSize = len;
skipBOM((const char*&)content, (int&)contentSize);
r = luaL_loadbuffer(L, (char*)content, contentSize, chunkName);
free(result); free(result);
} }
else else