From owner-svn-src-all@FreeBSD.ORG Wed Dec 29 21:38:00 2010 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C54BF1065674; Wed, 29 Dec 2010 21:38:00 +0000 (UTC) (envelope-from jilles@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id B449D8FC18; Wed, 29 Dec 2010 21:38:00 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id oBTLc0lK013950; Wed, 29 Dec 2010 21:38:00 GMT (envelope-from jilles@svn.freebsd.org) Received: (from jilles@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oBTLc05T013948; Wed, 29 Dec 2010 21:38:00 GMT (envelope-from jilles@svn.freebsd.org) Message-Id: <201012292138.oBTLc05T013948@svn.freebsd.org> From: Jilles Tjoelker Date: Wed, 29 Dec 2010 21:38:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r216809 - head/usr.bin/printf X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 29 Dec 2010 21:38:00 -0000 Author: jilles Date: Wed Dec 29 21:38:00 2010 New Revision: 216809 URL: http://svn.freebsd.org/changeset/base/216809 Log: 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. Modified: head/usr.bin/printf/printf.c Modified: head/usr.bin/printf/printf.c ============================================================================== --- head/usr.bin/printf/printf.c Wed Dec 29 21:04:10 2010 (r216808) +++ head/usr.bin/printf/printf.c Wed Dec 29 21:38:00 2010 (r216809) @@ -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);