From 33db85f2eefe15fac8f795aff5e3d3e554bfe83d Mon Sep 17 00:00:00 2001 From: Mitch Freeman <65987027+neckkola@users.noreply.github.com> Date: Mon, 6 Jan 2025 01:45:28 -0400 Subject: [PATCH] [Fix] Repair a EQEMUConfig Memory Leak (#4584) Co-authored-by: Mitch Freeman --- common/eqemu_config.h | 2 +- zone/zone_config.h | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/common/eqemu_config.h b/common/eqemu_config.h index 7e9e3b341..0ce295ece 100644 --- a/common/eqemu_config.h +++ b/common/eqemu_config.h @@ -137,9 +137,9 @@ class EQEmuConfig { } - virtual ~EQEmuConfig() {} public: + virtual ~EQEmuConfig() {} // Produce a const singleton static const EQEmuConfig *get() diff --git a/zone/zone_config.h b/zone/zone_config.h index a8e7401b6..e527e0601 100644 --- a/zone/zone_config.h +++ b/zone/zone_config.h @@ -43,11 +43,13 @@ class ZoneConfig : public EQEmuConfig { } // Load the config - static bool LoadConfig(const std::string& path = "") { - if (_zone_config != nullptr) - delete _zone_config; - _zone_config=new ZoneConfig; - _config=_zone_config; + static bool LoadConfig(const std::string &path = "") + { + safe_delete(_zone_config); + safe_delete(_config); + + _zone_config = new ZoneConfig; + _config = _zone_config; return _config->parseFile(path); }