pldd: Fix resource leak and missing check if fopen failed
Fixes Coverity CID 66903 Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This commit is contained in:
parent
79edb254ac
commit
bb7ad4ed64
@ -115,12 +115,16 @@ main (int argc, char *argv[])
|
|||||||
if (!fd)
|
if (!fd)
|
||||||
error (1, ENOENT, "cannot open /proc/%d", pid);
|
error (1, ENOENT, "cannot open /proc/%d", pid);
|
||||||
fscanf (fd, "%d", &winpid);
|
fscanf (fd, "%d", &winpid);
|
||||||
|
fclose (fd);
|
||||||
|
|
||||||
exefile = (char *) malloc (32);
|
exefile = (char *) malloc (32);
|
||||||
exename = (char *) malloc (MAX_PATH);
|
exename = (char *) malloc (MAX_PATH);
|
||||||
sprintf (exefile, "/proc/%d/exename", pid);
|
sprintf (exefile, "/proc/%d/exename", pid);
|
||||||
fd = fopen (exefile, "rb");
|
fd = fopen (exefile, "rb");
|
||||||
|
if (!fd)
|
||||||
|
error (1, ENOENT, "cannot open /proc/%d", pid);
|
||||||
fscanf (fd, "%s", exename);
|
fscanf (fd, "%s", exename);
|
||||||
|
fclose (fd);
|
||||||
|
|
||||||
hProcess = OpenProcess (PROCESS_QUERY_INFORMATION | PROCESS_VM_READ,
|
hProcess = OpenProcess (PROCESS_QUERY_INFORMATION | PROCESS_VM_READ,
|
||||||
0, winpid);
|
0, winpid);
|
||||||
|
Loading…
Reference in New Issue
Block a user