From 7cc072d1be3a040449b370613b3e0ec6763d5513 Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Wed, 18 Feb 2015 11:19:23 +0000 Subject: [PATCH] base: fix a data loss bug in the avl_tree copy constructor. --- src/lol/base/avl_tree.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/lol/base/avl_tree.h b/src/lol/base/avl_tree.h index 81ebb975..a7989de8 100644 --- a/src/lol/base/avl_tree.h +++ b/src/lol/base/avl_tree.h @@ -39,10 +39,13 @@ public: avl_tree & operator=(avl_tree const & other) { - clear(); + if (&other != this) + { + clear(); - for (auto it : other) - insert(it.key, it.value); + for (auto it : other) + insert(it.key, it.value); + } return *this; }