From 84ba8d50418b088901c2a36f99a1842e17c8fa33 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sun, 13 May 2012 23:14:04 +0000 Subject: Correctly handle Sord::Node self-assignment. git-svn-id: http://svn.drobilla.net/sord/trunk@223 3d64ff67-21c5-427c-a301-fe4f08042e5a --- NEWS | 1 + sord/sordmm.hpp | 12 +++++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/NEWS b/NEWS index c75df6a..32c4c78 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,7 @@ sord (9999) unstable; * sordmm.hpp: Add indices and graphs parameters to Model constructor * sordmm.hpp: Remove overzealous URI scheme assertion + * sordmm.hpp: Correctly handle Sord::Node self-assignment -- David Robillard 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; } -- cgit v1.2.1