mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
Double-free emergency fix for virtual resources
- vres_GetMap guarantees the same memory for the same lump id, provided it's active - vres_Free won't delete curmapvirt unless you do some silly temp pointer stuff
This commit is contained in:
parent
87aab3c881
commit
b4197a2263
3 changed files with 22 additions and 2 deletions
|
|
@ -8280,8 +8280,15 @@ boolean P_LoadLevel(boolean fromnetsave, boolean reloadinggamestate)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now safe to free.
|
// Now safe to free.
|
||||||
vres_Free(curmapvirt);
|
// We do the following silly
|
||||||
curmapvirt = NULL;
|
// construction because vres_Free
|
||||||
|
// no-sells deletions of pointers
|
||||||
|
// that are == curmapvirt.
|
||||||
|
{
|
||||||
|
virtres_t *temp = curmapvirt;
|
||||||
|
curmapvirt = NULL;
|
||||||
|
vres_Free(temp);
|
||||||
|
}
|
||||||
|
|
||||||
if (!reloadinggamestate)
|
if (!reloadinggamestate)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,7 @@ extern boolean levelloading;
|
||||||
extern UINT8 levelfadecol;
|
extern UINT8 levelfadecol;
|
||||||
|
|
||||||
extern lumpnum_t lastloadedmaplumpnum; // for comparative savegame
|
extern lumpnum_t lastloadedmaplumpnum; // for comparative savegame
|
||||||
|
extern virtres_t *curmapvirt;
|
||||||
|
|
||||||
/* for levelflat type */
|
/* for levelflat type */
|
||||||
enum
|
enum
|
||||||
|
|
|
||||||
12
src/w_wad.c
12
src/w_wad.c
|
|
@ -2354,6 +2354,12 @@ virtres_t* vres_GetMap(lumpnum_t lumpnum)
|
||||||
virtlump_t* vlumps = NULL;
|
virtlump_t* vlumps = NULL;
|
||||||
size_t numlumps = 0;
|
size_t numlumps = 0;
|
||||||
|
|
||||||
|
if (lastloadedmaplumpnum == lumpnum && curmapvirt != NULL)
|
||||||
|
{
|
||||||
|
// Avoid duplicating all our hard work.
|
||||||
|
return curmapvirt;
|
||||||
|
}
|
||||||
|
|
||||||
if (W_IsLumpWad(lumpnum))
|
if (W_IsLumpWad(lumpnum))
|
||||||
{
|
{
|
||||||
UINT32 realentry;
|
UINT32 realentry;
|
||||||
|
|
@ -2430,6 +2436,12 @@ virtres_t* vres_GetMap(lumpnum_t lumpnum)
|
||||||
*/
|
*/
|
||||||
void vres_Free(virtres_t* vres)
|
void vres_Free(virtres_t* vres)
|
||||||
{
|
{
|
||||||
|
if (vres == curmapvirt)
|
||||||
|
{
|
||||||
|
// No-sell multiple references.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
while (vres->numlumps--)
|
while (vres->numlumps--)
|
||||||
{
|
{
|
||||||
if (vres->vlumps[vres->numlumps].data)
|
if (vres->vlumps[vres->numlumps].data)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue