Fix memory leak generating .tex files. (#295)

This commit is contained in:
Prince Frizzy 2023-02-23 00:44:51 -05:00 committed by GitHub
parent 71a4196caf
commit 7e04c8acca
1 changed files with 7 additions and 0 deletions

View File

@ -417,6 +417,8 @@ static void DynOS_Tex_GeneratePack_Recursive(const SysPath &aPackFolder, SysPath
SysPath _RelativePath = fstring("%s%s", aRelativePath.c_str(), _PackEnt->d_name);
if (containsC && !is_level_number_png(_RelativePath)) {
// Don't forgot to free the texture data we've read.
Delete<TexData>(_TexData);
continue;
}
@ -433,6 +435,8 @@ static void DynOS_Tex_GeneratePack_Recursive(const SysPath &aPackFolder, SysPath
// if we aren't overriding a texture, only generate textures in the output directory
SysPath _OutputFolder = fstring("%s/", aOutputFolder.c_str());
if (_OverrideName == NULL && (!aAllowCustomTextures || strcmp(_DirPath.c_str(), _OutputFolder.c_str()))) {
// Don't forgot to free the texture data we've read.
Delete<TexData>(_TexData);
continue;
}
@ -444,6 +448,9 @@ static void DynOS_Tex_GeneratePack_Recursive(const SysPath &aPackFolder, SysPath
}
DynOS_Tex_WriteBinary(aGfxData, _OutputPath, _BaseName, _TexData, (_OverrideName != NULL));
// Don't forgot to free the texture data we've read.
Delete<TexData>(_TexData);
}
closedir(_PackDir);