From e87d4b88ec620144acc270a77fc7e5f2070f75f5 Mon Sep 17 00:00:00 2001 From: toaster Date: Sat, 25 Feb 2023 14:42:40 +0000 Subject: [PATCH] PR_SaveProfiles: Do not attempt to save if Guest profile data hasn't been initialised yet. - This only happens at the very end of PR_LoadProfiles, so it marks the clear point data is good. - Resolves #451 --- src/k_profiles.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/k_profiles.c b/src/k_profiles.c index 5a9ddd75a..75f2e77b4 100644 --- a/src/k_profiles.c +++ b/src/k_profiles.c @@ -219,6 +219,12 @@ void PR_SaveProfiles(void) UINT8 i, j, k; savebuffer_t save = {0}; + if (profilesList[PROFILE_GUEST] == NULL) + { + // Profiles have not been loaded yet, don't overwrite with garbage. + return; + } + if (P_SaveBufferAlloc(&save, sizeof(UINT32) + (numprofiles * sizeof(profile_t))) == false) { I_Error("No more free memory for saving profiles\n");