summaryrefslogtreecommitdiffstats
path: root/winsup/cygwin/syscalls.cc
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2014-06-23 19:05:15 +0000
committerCorinna Vinschen <corinna@vinschen.de>2014-06-23 19:05:15 +0000
commit8431e478d2f74ebf0bcfd2bc4c71e3c391fc7753 (patch)
treed3de9519039b3fb0e2536eabbabd2445015e902b /winsup/cygwin/syscalls.cc
parentcf06a0b18cf8dd93531f73e2a31f0c72389e84ec (diff)
downloadcygnal-8431e478d2f74ebf0bcfd2bc4c71e3c391fc7753.tar.gz
cygnal-8431e478d2f74ebf0bcfd2bc4c71e3c391fc7753.tar.bz2
cygnal-8431e478d2f74ebf0bcfd2bc4c71e3c391fc7753.zip
* spawn.cc (find_exec): Initialize err (CID 60111).
* strace.cc (strace::activate): Fix potential buffer overrun (CID 59938) * syscalls.cc (popen): Close parent pipe descriptor via fclosing fp on error to avoid resource leak (CID 59981). * thread.cc (pthread::exit): Avoid accessing cygtls member after deleting "this" (CID 60217).
Diffstat (limited to 'winsup/cygwin/syscalls.cc')
-rw-r--r--winsup/cygwin/syscalls.cc13
1 files changed, 11 insertions, 2 deletions
diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc
index de8cf119c..9edacd520 100644
--- a/winsup/cygwin/syscalls.cc
+++ b/winsup/cygwin/syscalls.cc
@@ -4355,8 +4355,17 @@ popen (const char *command, const char *in_type)
/* If we reach here we've seen an error but the pipe handles are open.
Close them and return NULL. */
int save_errno = get_errno ();
- close (fds[0]);
- close (fds[1]);
+ if (fp)
+ {
+ /* Must fclose fp to avoid memory leak. */
+ fclose (fp);
+ close (fds[myix ^ 1]);
+ }
+ else
+ {
+ close (fds[0]);
+ close (fds[1]);
+ }
set_errno (save_errno);
#undef rw