Fixed another serious bug where deleting menus and not returning PLUGIN_HANDLED would cause the iterator to fail and crash

This commit is contained in:
David Anderson 2006-11-21 23:59:21 +00:00
parent c15a23a2a7
commit db7dc509e0
6 changed files with 35 additions and 11 deletions

View File

@ -87,6 +87,10 @@ void MenuMngr::removeMenuId(int id)
{ {
if (c->menuid == id) if (c->menuid == id)
{ {
if (m_watch_iter.a == c)
{
++m_watch_iter;
}
if (lc) if (lc)
lc->next = c->next; lc->next = c->next;
else else
@ -140,4 +144,13 @@ void MenuMngr::clear()
} }
} }
MenuMngr::iterator MenuMngr::SetWatchIter(MenuMngr::iterator iter)
{
MenuMngr::iterator old = m_watch_iter;
m_watch_iter = iter;
return old;
}
int MenuMngr::MenuIdEle::uniqueid = 0; int MenuMngr::MenuIdEle::uniqueid = 0;

View File

@ -76,7 +76,8 @@ private:
} *headcmd; } *headcmd;
public: public:
MenuMngr() { headid = 0; headcmd = 0; } MenuMngr() : m_watch_iter(end())
{ headid = NULL; headcmd = NULL; }
~MenuMngr(); ~MenuMngr();
// Interface // Interface
@ -89,6 +90,7 @@ public:
class iterator class iterator
{ {
friend class MenuMngr;
MenuCommand* a; MenuCommand* a;
public: public:
iterator(MenuCommand*aa) : a(aa) {} iterator(MenuCommand*aa) : a(aa) {}
@ -101,6 +103,11 @@ public:
inline iterator begin() const { return iterator(headcmd); } inline iterator begin() const { return iterator(headcmd); }
inline iterator end() const { return iterator(0); } inline iterator end() const { return iterator(0); }
MenuMngr::iterator SetWatchIter(MenuMngr::iterator iter);
inline MenuMngr::iterator GetWatchIter() { return m_watch_iter; }
private:
MenuMngr::iterator m_watch_iter;
}; };
#endif //MENUS_H #endif //MENUS_H

View File

@ -73,7 +73,7 @@
#define AMXXLOG_Log g_log.Log #define AMXXLOG_Log g_log.Log
#define AMXXLOG_Error g_log.LogError #define AMXXLOG_Error g_log.LogError
#define AMX_VERSION "1.76b" #define AMX_VERSION "1.76c"
extern AMX_NATIVE_INFO core_Natives[]; extern AMX_NATIVE_INFO core_Natives[];
extern AMX_NATIVE_INFO time_Natives[]; extern AMX_NATIVE_INFO time_Natives[];

View File

@ -901,6 +901,7 @@ void C_ClientCommand(edict_t *pEntity)
pPlayer->menu = 0; pPlayer->menu = 0;
MenuMngr::iterator a = g_menucmds.begin(); MenuMngr::iterator a = g_menucmds.begin();
MenuMngr::iterator old = g_menucmds.SetWatchIter(a);
while (a) while (a)
{ {
@ -940,9 +941,16 @@ void C_ClientCommand(edict_t *pEntity)
if (ret & 1) RETURN_META(MRES_SUPERCEDE); if (ret & 1) RETURN_META(MRES_SUPERCEDE);
} }
} }
if (g_menucmds.GetWatchIter() != a)
{
a = g_menucmds.GetWatchIter();
} else {
++a; ++a;
} }
} }
g_menucmds.SetWatchIter(old);
}
} }
/* check for PLUGIN_HANDLED_MAIN and block hl call if needed */ /* check for PLUGIN_HANDLED_MAIN and block hl call if needed */

View File

@ -778,10 +778,6 @@
RelativePath="..\md5.h" RelativePath="..\md5.h"
> >
</File> </File>
<File
RelativePath="..\menus.h"
>
</File>
<File <File
RelativePath="..\messages.h" RelativePath="..\messages.h"
> >

View File

@ -27,8 +27,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
// //
VS_VERSION_INFO VERSIONINFO VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,7,6,2 FILEVERSION 1,7,6,3
PRODUCTVERSION 1,7,6,2 PRODUCTVERSION 1,7,6,3
FILEFLAGSMASK 0x17L FILEFLAGSMASK 0x17L
#ifdef _DEBUG #ifdef _DEBUG
FILEFLAGS 0x1L FILEFLAGS 0x1L
@ -45,12 +45,12 @@ BEGIN
BEGIN BEGIN
VALUE "Comments", "AMX Mod X" VALUE "Comments", "AMX Mod X"
VALUE "FileDescription", "AMX Mod X" VALUE "FileDescription", "AMX Mod X"
VALUE "FileVersion", "1.76b" VALUE "FileVersion", "1.76c"
VALUE "InternalName", "amxmodx" VALUE "InternalName", "amxmodx"
VALUE "LegalCopyright", "Copyright (c) 2004-2006, AMX Mod X Dev Team" VALUE "LegalCopyright", "Copyright (c) 2004-2006, AMX Mod X Dev Team"
VALUE "OriginalFilename", "amxmodx_mm.dll" VALUE "OriginalFilename", "amxmodx_mm.dll"
VALUE "ProductName", "AMX Mod X" VALUE "ProductName", "AMX Mod X"
VALUE "ProductVersion", "1.76b" VALUE "ProductVersion", "1.76c"
END END
END END
BLOCK "VarFileInfo" BLOCK "VarFileInfo"