Re: [Crystal-cvs] SF.net SVN: crystal:[39210] CS/trunk/include/csutil/weakkeyedhash.h
Vincent Knecht <[email protected]>
| Newsgroups | gmane.comp.graphics.crystalspace.devel |
|---|---|
| Message-ID | <CAGsPR3jgiK-+1Wcp+iduojYfGm=s3OQ6vzGTpWeShczwRXzEJg__11030.4687441841$1363903694$gmane$org@mail.gmail.com> |
2013/3/21 Mike Gist <[email protected]>: > On 21 March 2013 20:50, Vincent Knecht <[email protected]> wrote: >> >> 2013/3/21 <[email protected]>: >> > Revision: 39210 >> > http://sourceforge.net/p/crystal/code/39210 >> > Author: res2002 >> > Date: 2013-03-21 17:23:13 +0000 (Thu, 21 Mar 2013) >> > Log Message: >> > ----------- >> > csutil/WeakKeyedHash: Fix out of bounds array access >> > >> > Modified Paths: >> > -------------- >> > CS/trunk/include/csutil/weakkeyedhash.h >> > >> > Modified: CS/trunk/include/csutil/weakkeyedhash.h >> > =================================================================== >> > --- CS/trunk/include/csutil/weakkeyedhash.h 2013-03-21 16:52:29 UTC >> > (rev 39209) >> > +++ CS/trunk/include/csutil/weakkeyedhash.h 2013-03-21 17:23:13 UTC >> > (rev 39210) >> > @@ -63,8 +63,7 @@ >> > if (this->Elements.GetSize() == 0) return fallback; >> > typename Superclass::ElementArray& values = >> > this->Elements[csHashComputer<K>::ComputeHash (key) % >> > this->Modulo]; >> > - const size_t len = values.GetSize (); >> > - for (size_t i = 0; i < len; ++i) >> > + for (size_t i = 0; i < values.GetSize (); ++i) >> > { >> > const typename Superclass::Element& v = values[i]; >> > // Delete any elements with 'invalid' keys while searching >> >> Hello :-) >> I'm missing something (knowledge, I guess ;-) >> What's the difference ? How was the previous code wrong ? > > > The size of 'values' can change due to deletions inside the loop, so 'i' > needs to be compared against the new size every iteration. Thanks ! ------------------------------------------------------------------------------ Everyone hates slow websites. So do we. Make your web apps faster with AppDynamics Download AppDynamics Lite for free today: http://p.sf.net/sfu/appdyn_d2d_mar