From 64d0ae5e6951ec973f46b5eae6a5f7f41c001881 Mon Sep 17 00:00:00 2001 From: Simon Rozman Date: Tue, 25 Oct 2016 14:13:03 +0200 Subject: [PATCH] Issue with dplhandle<>::operator=() not overwriting non-NULL object with NULL one fixed --- include/WinStd/Common.h | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/include/WinStd/Common.h b/include/WinStd/Common.h index ec012f77..7ca09989 100644 --- a/include/WinStd/Common.h +++ b/include/WinStd/Common.h @@ -772,14 +772,21 @@ namespace winstd inline dplhandle& operator=(_In_ const dplhandle &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; }