mirror of
https://github.com/boostorg/unordered.git
synced 2026-02-01 09:02:10 +00:00
Fix exception bug in asssignment.
The hash and key equality functions were assigned before allocating new buckets. If that allocation failed, then the existing elements would be left in place - so if accessed after the exception they could be in the wrong buckets or equivalent elements could be incorrectly grouped together.
This commit is contained in:
@@ -111,16 +111,28 @@ namespace test {
|
||||
exceptions_enable(exceptions_enable const&);
|
||||
|
||||
bool old_value_;
|
||||
bool released_;
|
||||
public:
|
||||
exceptions_enable(bool enable)
|
||||
: old_value_(exceptions_enabled)
|
||||
: old_value_(exceptions_enabled), released_(false)
|
||||
{
|
||||
exceptions_enabled = enable;
|
||||
}
|
||||
|
||||
~exceptions_enable()
|
||||
{
|
||||
exceptions_enabled = old_value_;
|
||||
if (!released_) {
|
||||
exceptions_enabled = old_value_;
|
||||
released_ = true;
|
||||
}
|
||||
}
|
||||
|
||||
void release()
|
||||
{
|
||||
if (!released_) {
|
||||
exceptions_enabled = old_value_;
|
||||
released_ = true;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user