summaryrefslogtreecommitdiffhomepage
path: root/procps/top.c
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2002-09-20 07:33:18 +0000
committerEric Andersen <andersen@codepoet.org>2002-09-20 07:33:18 +0000
commit3a1d8377ab4b17f110831d324cbd612b09fb40f8 (patch)
tree8e27126a6de30c50aac69c08fc3ded7215f162a5 /procps/top.c
parent19feada06f0428dba579e2cf6d7e48b9ddc80de1 (diff)
don't leak FILEs
Diffstat (limited to 'procps/top.c')
-rw-r--r--procps/top.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/procps/top.c b/procps/top.c
index 8e5767e41..f6bbb23cd 100644
--- a/procps/top.c
+++ b/procps/top.c
@@ -212,6 +212,8 @@ static void read_status(int num, status_t *s)
fp = fopen(status, "r");
if (!fp) {
strncpy(s->pid, "EXIT", sizeof(s->pid));
+ s->pid[sizeof(s->pid)-1] = '\0';
+ fclose(fp);
continue;
}
@@ -296,6 +298,7 @@ static status_t *read_info(int num, struct dirent **namelist)
sprintf(cmdline, "%s/cmdline", s->pid);
fp = fopen(cmdline, "r");
if (!fp) {
+ fclose(fp);
perror("fopen('cmdline')");
return NULL;
}