From ddd8b7e5bb720b9966efe03a5a4dbca7716c1ea5 Mon Sep 17 00:00:00 2001 From: terminx Date: Thu, 26 Jul 2018 16:34:03 +0000 Subject: [PATCH] Cheap fix for load game menu crash git-svn-id: https://svn.eduke32.com/eduke32@6957 1a8010ca-5511-0410-912e-c29ae57300e0 --- source/duke3d/src/savegame.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/source/duke3d/src/savegame.cpp b/source/duke3d/src/savegame.cpp index 5425ec8a2..707e66264 100644 --- a/source/duke3d/src/savegame.cpp +++ b/source/duke3d/src/savegame.cpp @@ -205,8 +205,11 @@ static void ReadSaveGameHeaders_Internal(void) // potentially overallocating but programmatically simple size_t const numfiles = countcache1dfind(findfiles_default); size_t const internalsavesize = sizeof(menusave_t) * numfiles; + g_internalsaves = (menusave_t *)Xrealloc(g_internalsaves, internalsavesize); - g_internalsaves->clear(); + + if (internalsavesize) + g_internalsaves->clear(); g_numinternalsaves = 0; ReadSaveGameHeaders_CACHE1D(findfiles_default); @@ -222,8 +225,12 @@ static void ReadSaveGameHeaders_Internal(void) } } size_t const menusavesize = sizeof(menusave_t) * g_nummenusaves; + g_menusaves = (menusave_t *)Xrealloc(g_menusaves, menusavesize); - g_menusaves->clear(); + + if (menusavesize) + g_menusaves->clear(); + for (size_t x = g_numinternalsaves-1, y = 0; x < g_numinternalsaves; --x) { menusave_t & msv = g_internalsaves[x];