4
0
mirror of git://sourceware.org/git/newlib-cygwin.git synced 2025-02-08 10:09:32 +08:00

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 committed by Ken Brown
parent 762d6fd6dd
commit 518f0b8ef9

View File

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