diff options
author | David Robillard <d@drobilla.net> | 2012-05-13 23:14:04 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2012-05-13 23:14:04 +0000 |
commit | 84ba8d50418b088901c2a36f99a1842e17c8fa33 (patch) | |
tree | 508318dec45405d9af66894d09a2769031a6df00 /sord | |
parent | 54eb7caa4866b151983065385bfd54fc69d0d698 (diff) | |
download | sord-84ba8d50418b088901c2a36f99a1842e17c8fa33.tar.gz sord-84ba8d50418b088901c2a36f99a1842e17c8fa33.tar.bz2 sord-84ba8d50418b088901c2a36f99a1842e17c8fa33.zip |
Correctly handle Sord::Node self-assignment.
git-svn-id: http://svn.drobilla.net/sord/trunk@223 3d64ff67-21c5-427c-a301-fe4f08042e5a
Diffstat (limited to 'sord')
-rw-r--r-- | sord/sordmm.hpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/sord/sordmm.hpp b/sord/sordmm.hpp index ba59ed9..4f3b609 100644 --- a/sord/sordmm.hpp +++ b/sord/sordmm.hpp @@ -171,12 +171,14 @@ public: } } - const Node& operator=(const Node& other) { - if (_c_obj) { - sord_node_free(_world->c_obj(), _c_obj); + Node& operator=(const Node& other) { + if (&other != this) { + if (_c_obj) { + sord_node_free(_world->c_obj(), _c_obj); + } + _world = other._world; + _c_obj = other._c_obj ? sord_node_copy(other._c_obj) : NULL; } - _world = other._world; - _c_obj = other._c_obj ? sord_node_copy(other._c_obj) : NULL; return *this; } |