Issue with dplhandle<>::operator=() not overwriting non-NULL object with NULL one fixed

This commit is contained in:
Simon Rozman 2016-10-25 14:13:03 +02:00
parent 3872ddb465
commit 64d0ae5e69

View File

@ -772,14 +772,21 @@ namespace winstd
inline dplhandle<handle_type>& operator=(_In_ const dplhandle<handle_type> &h)
{
if (this != std::addressof(h)) {
handle_type h_new = duplicate_internal(h.m_h);
if (h_new) {
if (h.m_h) {
handle_type h_new = duplicate_internal(h.m_h);
if (h_new) {
if (m_h)
free_internal();
m_h = h_new;
} else
assert(0); // Could not duplicate the handle
} else {
if (m_h)
free_internal();
m_h = h_new;
} else if (h.m_h)
assert(0); // Could not duplicate the handle
m_h = NULL;
}
}
return *this;
}