diff options
author | unknown <jonas@perch.ndb.mysql.com> | 2008-01-30 11:58:10 +0100 |
---|---|---|
committer | unknown <jonas@perch.ndb.mysql.com> | 2008-01-30 11:58:10 +0100 |
commit | d132dd6299e03e9afe35638ba1bcca5ddb24ba44 (patch) | |
tree | e3488c8a966a6b48985ca6d7ea808f1236466ecb | |
parent | 950e7854440339b443742eeb5597c4c930f3ee4a (diff) | |
download | mariadb-git-d132dd6299e03e9afe35638ba1bcca5ddb24ba44.tar.gz |
ndb - bug#34160
make sure release of not added ptr does not corrupt hashtable
-rw-r--r-- | ndb/src/kernel/vm/DLHashTable.hpp | 22 | ||||
-rw-r--r-- | ndb/src/kernel/vm/DLHashTable2.hpp | 22 |
2 files changed, 36 insertions, 8 deletions
diff --git a/ndb/src/kernel/vm/DLHashTable.hpp b/ndb/src/kernel/vm/DLHashTable.hpp index acf53944b07..cc6802db2bc 100644 --- a/ndb/src/kernel/vm/DLHashTable.hpp +++ b/ndb/src/kernel/vm/DLHashTable.hpp @@ -45,8 +45,8 @@ public: /** * Seize element from pool - return i * - * Note must be either added using <b>add</b> or released - * using <b>release</b> + * Note *must* be added using <b>add</b> (even before hash.release) + * or be released using pool */ bool seize(Ptr<T> &); @@ -374,7 +374,14 @@ DLHashTable<T>::remove(Ptr<T> & ptr){ prevP->nextHash = next; } else { const Uint32 hv = ptr.p->hashValue() & mask; - hashValues[hv] = next; + if (hashValues[hv] == ptr.i) + { + hashValues[hv] = next; + } + else + { + // Will add assert in 5.1 + } } if(next != RNIL){ @@ -395,7 +402,14 @@ DLHashTable<T>::release(Ptr<T> & ptr){ prevP->nextHash = next; } else { const Uint32 hv = ptr.p->hashValue() & mask; - hashValues[hv] = next; + if (hashValues[hv] == ptr.i) + { + hashValues[hv] = next; + } + else + { + // Will add assert in 5.1 + } } if(next != RNIL){ diff --git a/ndb/src/kernel/vm/DLHashTable2.hpp b/ndb/src/kernel/vm/DLHashTable2.hpp index ad03e8ed3ba..20515af8cf6 100644 --- a/ndb/src/kernel/vm/DLHashTable2.hpp +++ b/ndb/src/kernel/vm/DLHashTable2.hpp @@ -43,8 +43,8 @@ public: /** * Seize element from pool - return i * - * Note must be either added using <b>add</b> or released - * using <b>release</b> + * Note *must* be added using <b>add</b> (even before hash.release) + * or be released using pool */ bool seize(Ptr<T> &); @@ -375,7 +375,14 @@ DLHashTable2<T, U>::remove(Ptr<T> & ptr){ prevP->nextHash = next; } else { const Uint32 hv = ptr.p->hashValue() & mask; - hashValues[hv] = next; + if (hashValues[hv] == ptr.i) + { + hashValues[hv] = next; + } + else + { + // Will add assert in 5.1 + } } if(next != RNIL){ @@ -396,7 +403,14 @@ DLHashTable2<T, U>::release(Ptr<T> & ptr){ prevP->nextHash = next; } else { const Uint32 hv = ptr.p->hashValue() & mask; - hashValues[hv] = next; + if (hashValues[hv] == ptr.i) + { + hashValues[hv] = next; + } + else + { + // Will add assert in 5.1 + } } if(next != RNIL){ |