In items.c in memcached-1.2.8, these arrays allow indices up to but
not including LARGEST_ID:

#define LARGEST_ID 255
...
static item *heads[LARGEST_ID];
static item *tails[LARGEST_ID];

So this comment (which appears twice) is confused:

   /* always true, warns: assert(it->slabs_clsid <= LARGEST_ID); */

The assert should be checking for clsid < LARGEST_ID, not <=.
And then the warning would go away.  Or was the intent always to have
256
entries in the arrays, not 255?

Similarly, this code in items.c should be checking >=, not >, as
heads[LARGEST_ID] would be out-of-bounds:

   if (slabs_clsid > LARGEST_ID) return NULL;
   it = heads[slabs_clsid];

IMHO the confusion stems from the fact that LARGEST_ID is not itself a
valid id, as the name seems to imply.

-Mat

Reply via email to