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,
(xxtea_long)_xxteaKeyLen,
&len);
skipBOM((const char*&)result, (int&)len);
r = luaL_loadbuffer(L, (char*)result, len, chunkName);
unsigned char* content = result;
xxtea_long contentSize = len;
skipBOM((const char*&)content, (int&)contentSize);
r = luaL_loadbuffer(L, (char*)content, contentSize, chunkName);
free(result);
}
else