diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2016-10-23 18:22:34 +0300 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2016-10-23 18:22:34 +0300 |
commit | bb7ad4ed647137404bd17f876b02d0a2fc5fd807 (patch) | |
tree | 8b3667bdb6d16936222e9cd37c0c57b185344015 /winsup/utils/pldd.c | |
parent | 79edb254aca9631fd1e83ac4fdfa27acdf564244 (diff) |
pldd: Fix resource leak and missing check if fopen failed
Fixes Coverity CID 66903
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Diffstat (limited to 'winsup/utils/pldd.c')
-rw-r--r-- | winsup/utils/pldd.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/winsup/utils/pldd.c b/winsup/utils/pldd.c index f97741950..f077e63ab 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); |