diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2016-10-23 17:22:34 +0200 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2016-10-23 17:22:34 +0200 |
commit | bb7ad4ed647137404bd17f876b02d0a2fc5fd807 (patch) | |
tree | 8b3667bdb6d16936222e9cd37c0c57b185344015 /winsup/utils | |
parent | 79edb254aca9631fd1e83ac4fdfa27acdf564244 (diff) | |
download | newlib-bb7ad4ed647137404bd17f876b02d0a2fc5fd807.zip newlib-bb7ad4ed647137404bd17f876b02d0a2fc5fd807.tar.gz newlib-bb7ad4ed647137404bd17f876b02d0a2fc5fd807.tar.bz2 |
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')
-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 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); |