summaryrefslogtreecommitdiffstats
path: root/winsup/cygwin/pipe.cc
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2011-06-30 09:37:36 +0000
committerCorinna Vinschen <corinna@vinschen.de>2011-06-30 09:37:36 +0000
commit9e1fd6bcf72c6cd45be5e4bb50ce604564e5706e (patch)
tree625ca41687e74b05628f12776547bd806062254f /winsup/cygwin/pipe.cc
parent53ffbf09d5b2a7ef94a7cdd1ccd488b880814352 (diff)
downloadcygnal-9e1fd6bcf72c6cd45be5e4bb50ce604564e5706e.tar.gz
cygnal-9e1fd6bcf72c6cd45be5e4bb50ce604564e5706e.tar.bz2
cygnal-9e1fd6bcf72c6cd45be5e4bb50ce604564e5706e.zip
* dtable.cc (fh_oom): New static fhandler storage.
(fh_calloc): New static function. Add a comment to explain why this is needed. (cnew): Call fh_calloc as placement argument. (build_fh_name): Check return code from cnew against address of fh_oom to test for out of memory condition. (fh_alloc): Ditto. (build_fh_pc): Avoid a crash due to useing a NULL fhandler. * pipe.cc (fhandler_pipe::create): Check if build_fh_dev returned a valid pointer before using it.
Diffstat (limited to 'winsup/cygwin/pipe.cc')
-rw-r--r--winsup/cygwin/pipe.cc16
1 files changed, 10 insertions, 6 deletions
diff --git a/winsup/cygwin/pipe.cc b/winsup/cygwin/pipe.cc
index ba38252d7..1050f3242 100644
--- a/winsup/cygwin/pipe.cc
+++ b/winsup/cygwin/pipe.cc
@@ -303,19 +303,23 @@ fhandler_pipe::create (fhandler_pipe *fhs[2], unsigned psize, int mode)
{
HANDLE r, w;
SECURITY_ATTRIBUTES *sa = sec_none_cloexec (mode);
- int res;
+ int res = -1;
int ret = create_selectable (sa, r, w, psize);
if (ret)
+ __seterrno_from_win_error (ret);
+ else if ((fhs[0] = (fhandler_pipe *) build_fh_dev (*piper_dev)) == NULL)
{
- __seterrno_from_win_error (ret);
- res = -1;
+ CloseHandle (r);
+ CloseHandle (w);
+ }
+ else if ((fhs[1] = (fhandler_pipe *) build_fh_dev (*pipew_dev)) == NULL)
+ {
+ delete fhs[0];
+ CloseHandle (w);
}
else
{
- fhs[0] = (fhandler_pipe *) build_fh_dev (*piper_dev);
- fhs[1] = (fhandler_pipe *) build_fh_dev (*pipew_dev);
-
mode |= mode & O_TEXT ?: O_BINARY;
fhs[0]->init (r, FILE_CREATE_PIPE_INSTANCE | GENERIC_READ, mode);
fhs[1]->init (w, FILE_CREATE_PIPE_INSTANCE | GENERIC_WRITE, mode);