diff --git a/core/logic/MemoryPointer.cpp b/core/logic/MemoryPointer.cpp index 753da0a4b..3c8f01de6 100644 --- a/core/logic/MemoryPointer.cpp +++ b/core/logic/MemoryPointer.cpp @@ -44,9 +44,10 @@ MemoryPointer::MemoryPointer(void* ptr, cell_t size) : m_ptr(ptr), m_owned(false MemoryPointer::~MemoryPointer() { - if (m_owned) + if (m_owned && m_ptr) { free(m_ptr); + m_ptr = nullptr; } } diff --git a/core/logic/smn_gameconfigs.cpp b/core/logic/smn_gameconfigs.cpp index f9b7768b2..1c3fc4085 100644 --- a/core/logic/smn_gameconfigs.cpp +++ b/core/logic/smn_gameconfigs.cpp @@ -214,7 +214,7 @@ static cell_t smn_GameConfGetAddressEx(IPluginContext *pCtx, const cell_t *param } char *key; - void* val; + void* val = nullptr; pCtx->LocalToString(params[2], &key); if (!gc->GetAddress(key, &val) || val == nullptr) @@ -248,7 +248,7 @@ static cell_t smn_GameConfGetMemSigEx(IPluginContext *pCtx, const cell_t *params } char *key; - void *val; + void *val = nullptr; pCtx->LocalToString(params[2], &key); if (!gc->GetMemSig(key, &val) || val == nullptr) diff --git a/plugins/include/sourcemod.inc b/plugins/include/sourcemod.inc index ffe68630b..9e949197f 100644 --- a/plugins/include/sourcemod.inc +++ b/plugins/include/sourcemod.inc @@ -121,7 +121,7 @@ methodmap GameData < Handle // // @param name Name of the property to find. // @return New MemoryPointer handle containing the address calculated on success, or null on failure. - public native Address GetAddressEx(const char[] name); + public native MemoryPointer GetAddressEx(const char[] name); // Returns a function address calculated from a signature. // @@ -134,7 +134,7 @@ methodmap GameData < Handle // // @param name Name of the property to find. // @return New MemoryPointer handle containing the address calculated on success, or null on failure. - public native Address GetMemSigEx(const char[] name); + public native MemoryPointer GetMemSigEx(const char[] name); }; /**