From 5e9cf961060f7de2a9be3d2384b0cc88e5739535 Mon Sep 17 00:00:00 2001 From: Alexander Batalov Date: Wed, 9 Nov 2022 11:41:53 +0300 Subject: [PATCH] Rename state structs Fixes UB leading to crash when exiting the game --- src/sfall_global_vars.cc | 6 +++--- src/sfall_lists.cc | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/sfall_global_vars.cc b/src/sfall_global_vars.cc index b6e2fb0..b62c0dc 100644 --- a/src/sfall_global_vars.cc +++ b/src/sfall_global_vars.cc @@ -6,18 +6,18 @@ namespace fallout { -struct State { +struct SfallGlobalVarsState { std::unordered_map vars; }; static bool sfallGlobalVarsStore(uint64_t key, int value); static bool sfallGlobalVarsFetch(uint64_t key, int& value); -static State* _state; +static SfallGlobalVarsState* _state; bool sfallGlobalVarsInit() { - _state = new (std::nothrow) State(); + _state = new (std::nothrow) SfallGlobalVarsState(); if (_state == nullptr) { return false; } diff --git a/src/sfall_lists.cc b/src/sfall_lists.cc index a9022bd..a582ae2 100644 --- a/src/sfall_lists.cc +++ b/src/sfall_lists.cc @@ -30,16 +30,16 @@ struct List { size_t pos = 0; }; -struct State { +struct SfallListsState { std::unordered_map lists; int nextListId = kInitialListId; }; -static State* _state = nullptr; +static SfallListsState* _state = nullptr; bool sfallListsInit() { - _state = new (std::nothrow) State(); + _state = new (std::nothrow) SfallListsState(); if (_state == nullptr) { return false; }