mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
RTech: fix rare crash in pak listing and unloading debug commands
g_pakGlobals->loadedPakCount counts the total number of paks loaded in the runtime, which can exceed PAK_MAX_LOADED_PAKS, which is the absolute maximum number of live loaded paks. So we would overrun the buffer if we had loaded more than PAK_MAX_LOADED_PAKS (512) paks during the life of the process. Just go over every pak memory instance and check if it isn't unloaded and then print out its details or perform the unload. We need to go over each slot because we can have a valid handle in slot 4 and slot 480 while having the rest inbetween marked as PAK_STATUS_FREED.
This commit is contained in:
parent
1766530af1
commit
9eeb0606e7
@ -22,7 +22,7 @@ static void Pak_ListPaks_f()
|
||||
|
||||
uint32_t numLoaded = 0;
|
||||
|
||||
for (int16_t i = 0, n = g_pakGlobals->loadedPakCount; i < n; ++i)
|
||||
for (uint16_t i = 0, n = PAK_MAX_LOADED_PAKS; i < n; ++i)
|
||||
{
|
||||
const PakLoadedInfo_s& info = g_pakGlobals->loadedPaks[i];
|
||||
|
||||
|
@ -263,7 +263,7 @@ PakLoadedInfo_s* Pak_GetPakInfo(const PakHandle_t pakId)
|
||||
//-----------------------------------------------------------------------------
|
||||
const PakLoadedInfo_s* Pak_GetPakInfo(const char* const pakName)
|
||||
{
|
||||
for (int16_t i = 0; i < g_pakGlobals->loadedPakCount; ++i)
|
||||
for (int16_t i = 0; i < PAK_MAX_LOADED_PAKS; ++i)
|
||||
{
|
||||
const PakLoadedInfo_s* const info = &g_pakGlobals->loadedPaks[i];
|
||||
if (!info)
|
||||
|
Loading…
x
Reference in New Issue
Block a user