Skip to content

Commit d9ee1af

Browse files
theSarrumqaisjp
andauthored
Fix engineGetModelTextures memory leak (#1704)
Co-authored-by: Qais Patankar <[email protected]>
1 parent 4c066c3 commit d9ee1af

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

Client/core/CCredits.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ CCredits::CCredits()
182182
"pentaflops\n"
183183
"knitz12\n"
184184
"ApeLsiN4eG\n"
185+
"theSarrum\n"
185186
"AlιAѕѕaѕѕιN\n"
186187
"PerikiyoXD\n"
187188
"correaAlex\n"

Client/mods/deathmatch/logic/luadefs/CLuaEngineDefs.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -1126,11 +1126,18 @@ int CLuaEngineDefs::EngineGetModelTextures(lua_State* luaVM)
11261126
if (argStream.HasErrors())
11271127
return luaL_error(luaVM, argStream.GetFullErrorMessage());
11281128

1129+
CLuaMain* pLuaMain = m_pLuaManager->GetVirtualMachine(luaVM);
1130+
CResource* pParentResource = pLuaMain->GetResource();
1131+
11291132
lua_newtable(luaVM);
11301133
for (const auto& pair : textureList)
11311134
{
11321135
CClientTexture* pTexture = g_pClientGame->GetManager()->GetRenderElementManager()->CreateTexture("", &std::get<1>(pair), RDEFAULT, RDEFAULT, RDEFAULT,
11331136
RFORMAT_UNKNOWN, TADDRESS_WRAP);
1137+
if (pTexture)
1138+
{
1139+
pTexture->SetParent(pParentResource->GetResourceDynamicEntity());
1140+
}
11341141
lua_pushstring(luaVM, std::get<0>(pair).c_str());
11351142
lua_pushelement(luaVM, pTexture);
11361143
lua_settable(luaVM, -3);

0 commit comments

Comments
 (0)