From: Eric Andersen Date: Fri, 20 Sep 2002 07:33:18 +0000 (-0000) Subject: don't leak FILEs X-Git-Tag: 0_60_5~64 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=3a1d8377ab4b17f110831d324cbd612b09fb40f8;p=oweals%2Fbusybox.git don't leak FILEs --- 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; }