mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-01-29 12:40:58 +00:00
Fix FreeMipmapColormap crash
This commit is contained in:
parent
23643e05c0
commit
c9ff8ec26b
1 changed files with 15 additions and 8 deletions
|
@ -771,18 +771,25 @@ void HWR_InitTextureCache(void)
|
|||
gr_textures2 = NULL;
|
||||
}
|
||||
|
||||
|
||||
// Callback function for HWR_FreeTextureCache.
|
||||
static void FreeMipmapColormap(INT32 patchnum, void *patch)
|
||||
{
|
||||
GLPatch_t* const grpatch = patch;
|
||||
GLPatch_t* const pat = patch;
|
||||
(void)patchnum; //unused
|
||||
while (grpatch->mipmap->nextcolormap)
|
||||
while (pat->mipmap && pat->mipmap->nextcolormap) // The mipmap must be valid, obviously
|
||||
{
|
||||
GLMipmap_t *grmip = grpatch->mipmap->nextcolormap;
|
||||
grpatch->mipmap->nextcolormap = grmip->nextcolormap;
|
||||
if (grmip->grInfo.data) Z_Free(grmip->grInfo.data);
|
||||
free(grmip);
|
||||
// Confusing at first, but pat->mipmap->nextcolormap
|
||||
// at the beginning of the loop is the first colormap
|
||||
// from the linked list of colormaps
|
||||
GLMipmap_t *next = pat->mipmap->nextcolormap;
|
||||
// Set the first colormap
|
||||
// to the one that comes after it
|
||||
pat->mipmap->nextcolormap = next->nextcolormap;
|
||||
// Free image data from memory
|
||||
if (next->grInfo.data)
|
||||
Z_Free(next->grInfo.data);
|
||||
// Free the old colormap from memory
|
||||
free(next);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -799,7 +806,7 @@ void HWR_FreeTextureCache(void)
|
|||
|
||||
// Alam: free the Z_Blocks before freeing it's users
|
||||
|
||||
// free all skin after each level: must be done after pfnClearMipMapCache!
|
||||
// free all patch colormaps after each level: must be done after ClearMipMapCache!
|
||||
for (i = 0; i < numwadfiles; i++)
|
||||
M_AATreeIterate(wadfiles[i]->hwrcache, FreeMipmapColormap);
|
||||
|
||||
|
|
Loading…
Reference in a new issue