Slightly rearrange the code to avoid returning without closing the
event handle.
if (!len)
return;
- if (!(evt = CreateEvent (NULL, false, false, NULL)))
- {
- __seterrno ();
- len = (size_t) -1;
- return;
- }
-
DWORD timeout = is_nonblocking () ? 0 : INFINITE;
DWORD waitret = cygwait (read_mtx, timeout);
switch (waitret)
len = (size_t) -1;
return;
}
+
+ if (!(evt = CreateEvent (NULL, false, false, NULL)))
+ {
+ __seterrno ();
+ len = (size_t) -1;
+ ReleaseMutex (read_mtx);
+ return;
+ }
+
while (nbytes < len)
{
ULONG_PTR nbytes_now = 0;