From 9af03ea4fc729f0a666186052c3a2a6bedc431ca Mon Sep 17 00:00:00 2001 From: jilles Date: Wed, 29 Dec 2010 21:38:00 +0000 Subject: printf: Do not use sh memory functions in sh builtin. These functions throw exceptions if they fail, possibly causing memory leaks. The normal out-of-memory handling suffices. The INTOFF around almost all of printf prevents memory leaks due to SIGINT. --- usr.bin/printf/printf.c | 13 ------------- 1 file changed, 13 deletions(-) (limited to 'usr.bin/printf') diff --git a/usr.bin/printf/printf.c b/usr.bin/printf/printf.c index d2fd37e2..34bb0a2 100644 --- a/usr.bin/printf/printf.c +++ b/usr.bin/printf/printf.c @@ -58,7 +58,6 @@ static const char rcsid[] = #ifdef SHELL #define main printfcmd #include "bltin/bltin.h" -#include "memalloc.h" #include "error.h" #endif @@ -256,11 +255,7 @@ printf_doformat(char *start, int *rval) char *p; int getout; -#ifdef SHELL - p = savestr(getstr()); -#else p = strdup(getstr()); -#endif if (p == NULL) { warnx("%s", strerror(ENOMEM)); return (NULL); @@ -269,11 +264,7 @@ printf_doformat(char *start, int *rval) *(fmt - 1) = 's'; PF(start, p); *(fmt - 1) = 'b'; -#ifdef SHELL - ckfree(p); -#else free(p); -#endif if (getout) return (fmt); break; @@ -342,11 +333,7 @@ mknum(char *str, char ch) len = strlen(str) + 2; if (len > copy_size) { newlen = ((len + 1023) >> 10) << 10; -#ifdef SHELL - if ((newcopy = ckrealloc(copy, newlen)) == NULL) -#else if ((newcopy = realloc(copy, newlen)) == NULL) -#endif { warnx("%s", strerror(ENOMEM)); return (NULL); -- cgit v1.1