diff options
author | danieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7> | 2009-09-30 16:28:43 +0000 |
---|---|---|
committer | danieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7> | 2009-09-30 16:28:43 +0000 |
commit | 5fd6471070ecf0f9a0074714c57211e922257014 (patch) | |
tree | 0fe57ecdcbc4f15ce5ccc1f53f37424020d50ce1 /src | |
parent | e279597c0b166d627bff09ecc8f1fcd28a631660 (diff) |
Detect, complain, and don't crash when objects are inserted into cull list twice
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11782 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r-- | src/cull_list.cpp | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/src/cull_list.cpp b/src/cull_list.cpp index c45dff46c..5715c3147 100644 --- a/src/cull_list.cpp +++ b/src/cull_list.cpp @@ -11,20 +11,27 @@ * --------------------------------------------------- */ -/* $Core */ - #include "inspircd.h" -#include "cull_list.h" +#include <typeinfo> void CullList::Apply() { - std::vector<classbase*> todel(list.begin(), list.end()); - list.clear(); - for(std::vector<classbase*>::iterator i = todel.begin(); i != todel.end(); i++) + std::set<classbase*> gone; + for(unsigned int i=0; i < list.size(); i++) { - classbase* c = *i; - c->cull(); - delete c; + classbase* c = list[i]; + if (gone.insert(c).second) + { + ServerInstance->Logs->Log("CULLLIST", DEBUG, "Deleting %s @%p", typeid(*c).name(), + (void*)c); + c->cull(); + delete c; + } + else + { + ServerInstance->Logs->Log("CULLLIST",DEBUG, "WARNING: Object @%p culled twice!", + (void*)c); + } } } |