Commit d132dd62 authored by unknown's avatar unknown

ndb - bug#34160

  make sure release of not added ptr does not corrupt hashtable

parent 950e7854
...@@ -45,8 +45,8 @@ public: ...@@ -45,8 +45,8 @@ public:
/** /**
* Seize element from pool - return i * Seize element from pool - return i
* *
* Note must be either added using <b>add</b> or released * Note *must* be added using <b>add</b> (even before hash.release)
* using <b>release</b> * or be released using pool
*/ */
bool seize(Ptr<T> &); bool seize(Ptr<T> &);
...@@ -374,8 +374,15 @@ DLHashTable<T>::remove(Ptr<T> & ptr){ ...@@ -374,8 +374,15 @@ DLHashTable<T>::remove(Ptr<T> & ptr){
prevP->nextHash = next; prevP->nextHash = next;
} else { } else {
const Uint32 hv = ptr.p->hashValue() & mask; const Uint32 hv = ptr.p->hashValue() & mask;
if (hashValues[hv] == ptr.i)
{
hashValues[hv] = next; hashValues[hv] = next;
} }
else
{
// Will add assert in 5.1
}
}
if(next != RNIL){ if(next != RNIL){
T * nextP = thePool.getPtr(next); T * nextP = thePool.getPtr(next);
...@@ -395,8 +402,15 @@ DLHashTable<T>::release(Ptr<T> & ptr){ ...@@ -395,8 +402,15 @@ DLHashTable<T>::release(Ptr<T> & ptr){
prevP->nextHash = next; prevP->nextHash = next;
} else { } else {
const Uint32 hv = ptr.p->hashValue() & mask; const Uint32 hv = ptr.p->hashValue() & mask;
if (hashValues[hv] == ptr.i)
{
hashValues[hv] = next; hashValues[hv] = next;
} }
else
{
// Will add assert in 5.1
}
}
if(next != RNIL){ if(next != RNIL){
T * nextP = thePool.getPtr(next); T * nextP = thePool.getPtr(next);
......
...@@ -43,8 +43,8 @@ public: ...@@ -43,8 +43,8 @@ public:
/** /**
* Seize element from pool - return i * Seize element from pool - return i
* *
* Note must be either added using <b>add</b> or released * Note *must* be added using <b>add</b> (even before hash.release)
* using <b>release</b> * or be released using pool
*/ */
bool seize(Ptr<T> &); bool seize(Ptr<T> &);
...@@ -375,8 +375,15 @@ DLHashTable2<T, U>::remove(Ptr<T> & ptr){ ...@@ -375,8 +375,15 @@ DLHashTable2<T, U>::remove(Ptr<T> & ptr){
prevP->nextHash = next; prevP->nextHash = next;
} else { } else {
const Uint32 hv = ptr.p->hashValue() & mask; const Uint32 hv = ptr.p->hashValue() & mask;
if (hashValues[hv] == ptr.i)
{
hashValues[hv] = next; hashValues[hv] = next;
} }
else
{
// Will add assert in 5.1
}
}
if(next != RNIL){ if(next != RNIL){
T * nextP = (T*)thePool.getPtr(next); // cast T * nextP = (T*)thePool.getPtr(next); // cast
...@@ -396,8 +403,15 @@ DLHashTable2<T, U>::release(Ptr<T> & ptr){ ...@@ -396,8 +403,15 @@ DLHashTable2<T, U>::release(Ptr<T> & ptr){
prevP->nextHash = next; prevP->nextHash = next;
} else { } else {
const Uint32 hv = ptr.p->hashValue() & mask; const Uint32 hv = ptr.p->hashValue() & mask;
if (hashValues[hv] == ptr.i)
{
hashValues[hv] = next; hashValues[hv] = next;
} }
else
{
// Will add assert in 5.1
}
}
if(next != RNIL){ if(next != RNIL){
T * nextP = (T*)thePool.getPtr(next); // cast T * nextP = (T*)thePool.getPtr(next); // cast
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment