[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: possible bug
- From: Peter Cawley <lua@...>
- Date: Fri, 27 Mar 2009 14:35:26 +0000
In getfreepos:
If t->lastfree > t->node, then the while body will execute, and after
t->lastfree--, t->lastfree >= t->node will be true, and t->lastfree
may be returned.
If t->lastfree <= t->node, then the while body will not execute, and
after t->lastfree--, t->lastfree < t->node will be true, and NULL will
be returned.
getfreepos is only called by newkey, and if the return value is NULL,
then the table is immediately rehashed, causing t->lastfree to be set
to a valid value again.
Therefore, IMO, not a bug.
On Fri, Mar 27, 2009 at 2:25 PM, Ralph Hempel
<rhempel@hempeldesigngroup.com> wrote:
> Roberto Ierusalimschy wrote:
>
>> In the second picture, it may really be a small bug. When the table
>> has no hash elements, t->node points to 'dummynode' but t->lastfree
>> also points to dummynode (because size is 0). Then the decrement in the
>> marked line [while (t->lastfree-- > t->node) {] will make t->lastfree
>> point to outside the dummynode_ "array".
>
> Funny, I'm in the process of going through that code right now
> in an effort to play around a bit with putting some of the Lua
> libraries into ROM.
>
> I guess one way to fix this is to have two dummynode entries in an
> array and point t->node at the first one and t->lasfree point
> at the second one...
>
> Ralph
>
>