#2 hashtable does not support negative pKeys

closed-fixed
None
5
2004-01-02
2003-09-12
No

When inserting an element in the hashtable and the pKey
is negative the bucket will be calculated to a negative
value. This will make it crash.
Discovered under Solaris, where the object id
(object->oid) is negative.
Changing all
int bucket = pKey % pTable->numBuckets;
in hashtable.c to this
int bucket = abs(pKey) % pTable->numBuckets;
will fix the bug.

Discussion

  • Henner Zeller

    Henner Zeller - 2004-01-02
    • status: open --> open-fixed
     
  • Henner Zeller

    Henner Zeller - 2004-01-02

    Logged In: YES
    user_id=42577

    Made the type the hashtable uses as key an unsigned type (it
    used to be a 'long', now it is a typedef unsinged long
    hashkey_t). Haven't tested it, but this should fix this bug almost
    certainly.

     
  • Henner Zeller

    Henner Zeller - 2004-01-02
    • assigned_to: nobody --> hzeller
    • status: open-fixed --> closed-fixed
     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks