From 1df654c6a1da605eab050839ec437e1bb1066751 Mon Sep 17 00:00:00 2001 From: Pavol Marko Date: Thu, 9 Sep 2004 15:05:06 +0000 Subject: [PATCH] registerSPForward now returing -1 if no func found --- amxmodx/CForward.cpp | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/amxmodx/CForward.cpp b/amxmodx/CForward.cpp index 99f52d30..9996256b 100755 --- a/amxmodx/CForward.cpp +++ b/amxmodx/CForward.cpp @@ -293,8 +293,10 @@ int CForwardMngr::registerSPForward(int func, AMX *amx, int numParams, const For if (!m_FreeSPForwards.empty()) { pForward = m_SPForwards[m_FreeSPForwards.front() >> 1]; - m_FreeSPForwards.pop(); pForward->Set(func, amx, numParams, paramTypes); + if (pForward->getFuncsNum() == 0) + return -1; + m_FreeSPForwards.pop(); } else { @@ -302,13 +304,14 @@ int CForwardMngr::registerSPForward(int func, AMX *amx, int numParams, const For if (!pForward) return -1; pForward->Set(func, amx, numParams, paramTypes); + if (pForward->getFuncsNum() == 0) + { + return -1; + delete pForward; + } + m_SPForwards.push_back(pForward); } - if (pForward->getFuncsNum() == 0) - { - unregisterSPForward(retVal); - return -1; - } return retVal; } @@ -319,9 +322,11 @@ int CForwardMngr::registerSPForward(const char *funcName, AMX *amx, int numParam if (!m_FreeSPForwards.empty()) { retVal = m_FreeSPForwards.front(); - m_FreeSPForwards.pop(); pForward = m_SPForwards[retVal>>1]; // >>1 because unregisterSPForward pushes the id which contains the sp flag pForward->Set(funcName, amx, numParams, paramTypes); + if (pForward->getFuncsNum() == 0) + return -1; + m_FreeSPForwards.pop(); } else { @@ -329,6 +334,11 @@ int CForwardMngr::registerSPForward(const char *funcName, AMX *amx, int numParam if (!pForward) return -1; pForward->Set(funcName, amx, numParams, paramTypes); + if (pForward->getFuncsNum() == 0) + { + delete pForward; + return -1; + } m_SPForwards.push_back(pForward); } return retVal;