Re: [Crystal-cvs] SF.net SVN: crystal:[39210] CS/trunk/include/csutil/weakkeyedhash.h
Mike Gist <[email protected]>
| Newsgroups | gmane.comp.graphics.crystalspace.devel |
|---|---|
| Message-ID | <CAONw8qaxiJ-9_O+TF8o7bUGz9YJzojH46juusgYaxmYr1vJ4kw__2509.05704820088$1363900355$gmane$org@mail.gmail.com> |
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. -- - Mike ------------------------------------------------------------------------------ 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 _______________________________________________ Crystal-develop mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/crystal-develop