]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Module priority 'shuffler' fix from Phoenix, bounds checks
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Tue, 24 Jun 2008 17:17:59 +0000 (17:17 +0000)
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Tue, 24 Jun 2008 17:17:59 +0000 (17:17 +0000)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@9934 e03df62e-2008-0410-955e-edbf42e46eb7

src/modules.cpp

index 9c608cb823493cc50138e6961fa5e025fc344c17..57790cd1b5b227c3d7aad4a6780a186cd7718a50 100644 (file)
@@ -335,10 +335,17 @@ bool ModuleManager::SetPriority(Module* mod, Implementation i, PriorityState s,
        {
                /* Suggestion from Phoenix, "shuffle" the modules to better retain call order */
                int incrmnt = 1;
+
                if (source > swap_pos)
                        incrmnt = -1;
+
                for (unsigned int j = source; j != swap_pos; j += incrmnt)
+               {
+                       if (( j + incrmnt > EventHandlers[i].size() - 1) || (j - incrmnt < 0))
+                               continue;
+
                        std::swap(EventHandlers[i][j], EventHandlers[i][j+incrmnt]);
+               }
        }
 
        return true;