Skip to content

Commit

Permalink
Fix engineGetModelTextures memory leak (#1704)
Browse files Browse the repository at this point in the history
Co-authored-by: Qais Patankar <[email protected]>
  • Loading branch information
theSarrum and qaisjp authored Oct 11, 2020
1 parent 4c066c3 commit d9ee1af
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions Client/core/CCredits.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ CCredits::CCredits()
"pentaflops\n"
"knitz12\n"
"ApeLsiN4eG\n"
"theSarrum\n"
"AlιAѕѕaѕѕιN\n"
"PerikiyoXD\n"
"correaAlex\n"
Expand Down
7 changes: 7 additions & 0 deletions Client/mods/deathmatch/logic/luadefs/CLuaEngineDefs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1126,11 +1126,18 @@ int CLuaEngineDefs::EngineGetModelTextures(lua_State* luaVM)
if (argStream.HasErrors())
return luaL_error(luaVM, argStream.GetFullErrorMessage());

CLuaMain* pLuaMain = m_pLuaManager->GetVirtualMachine(luaVM);
CResource* pParentResource = pLuaMain->GetResource();

lua_newtable(luaVM);
for (const auto& pair : textureList)
{
CClientTexture* pTexture = g_pClientGame->GetManager()->GetRenderElementManager()->CreateTexture("", &std::get<1>(pair), RDEFAULT, RDEFAULT, RDEFAULT,
RFORMAT_UNKNOWN, TADDRESS_WRAP);
if (pTexture)
{
pTexture->SetParent(pParentResource->GetResourceDynamicEntity());
}
lua_pushstring(luaVM, std::get<0>(pair).c_str());
lua_pushelement(luaVM, pTexture);
lua_settable(luaVM, -3);
Expand Down

0 comments on commit d9ee1af

Please sign in to comment.