This is the mail archive of the
cygwin-cvs@cygwin.com
mailing list for the Cygwin project.
[newlib-cygwin] pldd: Fix resource leak and missing check if fopen failed
- From: Corinna Vinschen <corinna at sourceware dot org>
- To: cygwin-cvs at sourceware dot org
- Date: 24 Oct 2016 09:25:02 -0000
- Subject: [newlib-cygwin] pldd: Fix resource leak and missing check if fopen failed
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=bb7ad4ed647137404bd17f876b02d0a2fc5fd807
commit bb7ad4ed647137404bd17f876b02d0a2fc5fd807
Author: Corinna Vinschen <corinna@vinschen.de>
Date: Sun Oct 23 17:22:34 2016 +0200
pldd: Fix resource leak and missing check if fopen failed
Fixes Coverity CID 66903
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Diff:
---
winsup/utils/pldd.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/winsup/utils/pldd.c b/winsup/utils/pldd.c
index f977419..f077e63 100644
--- a/winsup/utils/pldd.c
+++ b/winsup/utils/pldd.c
@@ -115,12 +115,16 @@ main (int argc, char *argv[])
if (!fd)
error (1, ENOENT, "cannot open /proc/%d", pid);
fscanf (fd, "%d", &winpid);
+ fclose (fd);
exefile = (char *) malloc (32);
exename = (char *) malloc (MAX_PATH);
sprintf (exefile, "/proc/%d/exename", pid);
fd = fopen (exefile, "rb");
+ if (!fd)
+ error (1, ENOENT, "cannot open /proc/%d", pid);
fscanf (fd, "%s", exename);
+ fclose (fd);
hProcess = OpenProcess (PROCESS_QUERY_INFORMATION | PROCESS_VM_READ,
0, winpid);