From b5c4aeab94b276e001819d22cc684a71caff564a Mon Sep 17 00:00:00 2001 From: Felipe Magno de Almeida Date: Fri, 15 Sep 2017 15:16:58 -0300 Subject: [PATCH] eo-cxx: Fix possible non-initialization in copy-constructor and move-constructor --- src/bindings/cxx/eo_cxx/eo_concrete.hh | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/bindings/cxx/eo_cxx/eo_concrete.hh b/src/bindings/cxx/eo_cxx/eo_concrete.hh index f02eb0cba0..e5966a31a5 100644 --- a/src/bindings/cxx/eo_cxx/eo_concrete.hh +++ b/src/bindings/cxx/eo_cxx/eo_concrete.hh @@ -72,6 +72,7 @@ struct concrete } concrete(concrete const& other) + : _eo_raw(nullptr) { if(other._eo_raw) _eo_raw = detail::ref(other._eo_raw); @@ -94,17 +95,15 @@ struct concrete } if(other._eo_raw) _eo_raw = detail::ref(other._eo_raw); + else + _eo_raw = nullptr; return *this; } concrete& operator=(concrete&& other) { - if(_eo_raw) - { - detail::unref(_eo_raw); - _eo_raw = nullptr; - } - std::swap(_eo_raw, other._eo_raw); + concrete tmp(other); + std::swap(*this, tmp); return *this; }