Cygwin: check path_conv_handle for NULL before trying to dup it

path_conv_handle::dup calls DuplicateHandle unconditionally,
but we only have a handle in some cases.  Check handle for being
non-NULL before calling DuplicateHandle.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This commit is contained in:
Corinna Vinschen 2021-02-10 10:39:03 +01:00
parent 5f0913df13
commit d0e0a59e78
1 changed files with 4 additions and 3 deletions

View File

@ -105,9 +105,10 @@ public:
} }
inline void dup (const path_conv_handle &pch) inline void dup (const path_conv_handle &pch)
{ {
if (!DuplicateHandle (GetCurrentProcess (), pch.handle (), if (pch.handle ()
GetCurrentProcess (), &hdl, && !DuplicateHandle (GetCurrentProcess (), pch.handle (),
0, TRUE, DUPLICATE_SAME_ACCESS)) GetCurrentProcess (), &hdl,
0, TRUE, DUPLICATE_SAME_ACCESS))
hdl = NULL; hdl = NULL;
} }
inline HANDLE handle () const { return hdl; } inline HANDLE handle () const { return hdl; }