mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 760342 - Check explicitly for mis-use of HashTable::Enum; r=luke
If a user does removeFront or rekeyFront on an Enum, then continues to use it, it will fail, potentially randomly. This patch makes the failure explicit in debug builds.
This commit is contained in:
parent
fc691d0a20
commit
3b9ff67eee
@ -142,21 +142,23 @@ class HashTable : private AllocPolicy
|
||||
protected:
|
||||
friend class HashTable;
|
||||
|
||||
Range(Entry *c, Entry *e) : cur(c), end(e) {
|
||||
Range(Entry *c, Entry *e) : cur(c), end(e), validEntry(true) {
|
||||
while (cur < end && !cur->isLive())
|
||||
++cur;
|
||||
}
|
||||
|
||||
Entry *cur, *end;
|
||||
DebugOnly<bool> validEntry;
|
||||
|
||||
public:
|
||||
Range() : cur(NULL), end(NULL) {}
|
||||
Range() : cur(NULL), end(NULL), validEntry(false) {}
|
||||
|
||||
bool empty() const {
|
||||
return cur == end;
|
||||
}
|
||||
|
||||
T &front() const {
|
||||
JS_ASSERT(validEntry);
|
||||
JS_ASSERT(!empty());
|
||||
return cur->t;
|
||||
}
|
||||
@ -165,6 +167,7 @@ class HashTable : private AllocPolicy
|
||||
JS_ASSERT(!empty());
|
||||
while (++cur < end && !cur->isLive())
|
||||
continue;
|
||||
validEntry = true;
|
||||
}
|
||||
};
|
||||
|
||||
@ -205,6 +208,7 @@ class HashTable : private AllocPolicy
|
||||
void removeFront() {
|
||||
table.remove(*this->cur);
|
||||
removed = true;
|
||||
this->validEntry = false;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -221,6 +225,7 @@ class HashTable : private AllocPolicy
|
||||
table.remove(*this->cur);
|
||||
table.add(l, e);
|
||||
added = true;
|
||||
this->validEntry = false;
|
||||
}
|
||||
|
||||
void rekeyFront(const Key &k) {
|
||||
|
@ -187,7 +187,6 @@ class WeakMap : public HashMap<Key, Value, HashPolicy, RuntimeAllocPolicy>, publ
|
||||
markedAny = true;
|
||||
e.rekeyFront(k);
|
||||
}
|
||||
JS_ASSERT_IF(keyIsMarked, gc::IsMarked(&e.front().value));
|
||||
}
|
||||
return markedAny;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user