eo-cxx: Fix possible non-initialization in copy-constructor and move-constructor

This commit is contained in:
Felipe Magno de Almeida 2017-09-15 15:16:58 -03:00
parent 6ded80a9b5
commit b5c4aeab94
1 changed files with 5 additions and 6 deletions

View File

@ -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;
}