From: Eric Andersen Date: Tue, 12 Dec 2000 23:45:36 +0000 (-0000) Subject: Mem leak fix from Matt Kraai X-Git-Tag: 0_48~11 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=f361ac29b0f94c85a8aeb1185301f8197f64fe42;p=oweals%2Fbusybox.git Mem leak fix from Matt Kraai --- diff --git a/lash.c b/lash.c index 9fc215c98..164d6f5c5 100644 --- a/lash.c +++ b/lash.c @@ -663,7 +663,7 @@ static int setupRedirections(struct childProgram *prog) static int getCommand(FILE * source, char *command) { - char *user,buf[255],*s; + char user[9],buf[255],*s; if (source == NULL) { if (local_pending_command) { @@ -678,7 +678,6 @@ static int getCommand(FILE * source, char *command) /* get User Name and setup prompt */ strcpy(prompt,( geteuid() != 0 ) ? "$ ":"# "); - user=xcalloc(sizeof(int), 9); my_getpwuid(user, geteuid()); /* get HostName */ @@ -723,9 +722,6 @@ static int getCommand(FILE * source, char *command) #endif } - /* don't leak memory */ - free(user); - if (!fgets(command, BUFSIZ - 2, source)) { if (source == stdin) printf("\n"); diff --git a/sh.c b/sh.c index 9fc215c98..164d6f5c5 100644 --- a/sh.c +++ b/sh.c @@ -663,7 +663,7 @@ static int setupRedirections(struct childProgram *prog) static int getCommand(FILE * source, char *command) { - char *user,buf[255],*s; + char user[9],buf[255],*s; if (source == NULL) { if (local_pending_command) { @@ -678,7 +678,6 @@ static int getCommand(FILE * source, char *command) /* get User Name and setup prompt */ strcpy(prompt,( geteuid() != 0 ) ? "$ ":"# "); - user=xcalloc(sizeof(int), 9); my_getpwuid(user, geteuid()); /* get HostName */ @@ -723,9 +722,6 @@ static int getCommand(FILE * source, char *command) #endif } - /* don't leak memory */ - free(user); - if (!fgets(command, BUFSIZ - 2, source)) { if (source == stdin) printf("\n"); diff --git a/shell/lash.c b/shell/lash.c index 9fc215c98..164d6f5c5 100644 --- a/shell/lash.c +++ b/shell/lash.c @@ -663,7 +663,7 @@ static int setupRedirections(struct childProgram *prog) static int getCommand(FILE * source, char *command) { - char *user,buf[255],*s; + char user[9],buf[255],*s; if (source == NULL) { if (local_pending_command) { @@ -678,7 +678,6 @@ static int getCommand(FILE * source, char *command) /* get User Name and setup prompt */ strcpy(prompt,( geteuid() != 0 ) ? "$ ":"# "); - user=xcalloc(sizeof(int), 9); my_getpwuid(user, geteuid()); /* get HostName */ @@ -723,9 +722,6 @@ static int getCommand(FILE * source, char *command) #endif } - /* don't leak memory */ - free(user); - if (!fgets(command, BUFSIZ - 2, source)) { if (source == stdin) printf("\n");