public inbox for cygwin-cvs@sourceware.org help / color / mirror / Atom feed
From: Ken Brown <kbrown@sourceware.org> To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin/cygwin-3_3-branch] Cygwin: fhandler_pipe::raw_read: fix handle leak Date: Wed, 24 Nov 2021 14:03:26 +0000 (GMT) [thread overview] Message-ID: <20211124140326.BA96A3858C27@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=384c78e8a73123734c19132e1732b5be67837c65 commit 384c78e8a73123734c19132e1732b5be67837c65 Author: Ken Brown <kbrown@cornell.edu> Date: Tue Nov 23 10:13:43 2021 -0500 Cygwin: fhandler_pipe::raw_read: fix handle leak Slightly rearrange code to avoid returning without closing the event handle. Diff: --- winsup/cygwin/fhandler_pipe.cc | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/winsup/cygwin/fhandler_pipe.cc b/winsup/cygwin/fhandler_pipe.cc index e92d313c7..25a092262 100644 --- a/winsup/cygwin/fhandler_pipe.cc +++ b/winsup/cygwin/fhandler_pipe.cc @@ -284,13 +284,6 @@ fhandler_pipe::raw_read (void *ptr, size_t& len) 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) @@ -314,6 +307,15 @@ fhandler_pipe::raw_read (void *ptr, size_t& len) 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;
reply other threads:[~2021-11-24 14:03 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20211124140326.BA96A3858C27@sourceware.org \ --to=kbrown@sourceware.org \ --cc=cygwin-cvs@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).