mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-10-01 01:26:01 -04:00
Fix CompositKey self assignment.
This commit is contained in:
parent
f767a098d6
commit
7e9343c697
@ -51,6 +51,11 @@ CompositeKey* CompositeKey::clone() const
|
|||||||
|
|
||||||
CompositeKey& CompositeKey::operator=(const CompositeKey& key)
|
CompositeKey& CompositeKey::operator=(const CompositeKey& key)
|
||||||
{
|
{
|
||||||
|
// handle self assignment as that would break when calling clear()
|
||||||
|
if (this == &key) {
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
clear();
|
clear();
|
||||||
|
|
||||||
Q_FOREACH (const Key* subKey, key.m_keys) {
|
Q_FOREACH (const Key* subKey, key.m_keys) {
|
||||||
|
@ -70,6 +70,10 @@ void TestKeys::testComposite()
|
|||||||
*compositeKey4 = *compositeKey3;
|
*compositeKey4 = *compositeKey3;
|
||||||
QCOMPARE(compositeKey3->rawKey(), compositeKey4->rawKey());
|
QCOMPARE(compositeKey3->rawKey(), compositeKey4->rawKey());
|
||||||
|
|
||||||
|
// test self-assignment
|
||||||
|
*compositeKey3 = *compositeKey3;
|
||||||
|
QCOMPARE(compositeKey3->rawKey(), compositeKey4->rawKey());
|
||||||
|
|
||||||
delete compositeKey3;
|
delete compositeKey3;
|
||||||
delete compositeKey4;
|
delete compositeKey4;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user