From: Joel E. Denny Date: Tue, 15 Dec 2009 09:07:39 +0000 (+0100) Subject: *printf: Fix memory leak. X-Git-Tag: v0.1~5038 X-Git-Url: http://erislabs.net/gitweb/?a=commitdiff_plain;h=2c0087ea00a28c65a7b118aaa00e768dcf5886ad;p=gnulib.git *printf: Fix memory leak. --- diff --git a/ChangeLog b/ChangeLog index 2756f670b..0f42ccf50 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2009-12-15 Joel E. Denny + Bruno Haible + + *printf: Fix memory leak. + * lib/fprintf.c (fprintf): Free memory allocated by vasnprintf. + * lib/vfprintf.c (vfprintf): Likewise. + * lib/dprintf.c (dprintf): Likewise. + * lib/vdprintf.c (vdprintf): Likewise. + 2009-12-14 Eric Blake accept4: adjust module dependencies diff --git a/lib/dprintf.c b/lib/dprintf.c index 70f992f0e..99ee6af7f 100644 --- a/lib/dprintf.c +++ b/lib/dprintf.c @@ -57,6 +57,9 @@ dprintf (int fd, const char *format, ...) return -1; } + if (output != buf) + free (output); + if (len > INT_MAX) { errno = EOVERFLOW; diff --git a/lib/fprintf.c b/lib/fprintf.c index eb1cf8e36..dc8fcfb0b 100644 --- a/lib/fprintf.c +++ b/lib/fprintf.c @@ -1,5 +1,5 @@ /* Formatted output to a stream. - Copyright (C) 2004, 2006-2008 Free Software Foundation, Inc. + Copyright (C) 2004, 2006-2009 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -63,6 +63,9 @@ fprintf (FILE *fp, const char *format, ...) return -1; } + if (output != buf) + free (output); + if (len > INT_MAX) { errno = EOVERFLOW; diff --git a/lib/vdprintf.c b/lib/vdprintf.c index 2b0da8a28..77c8c6ea0 100644 --- a/lib/vdprintf.c +++ b/lib/vdprintf.c @@ -54,6 +54,9 @@ vdprintf (int fd, const char *format, va_list args) return -1; } + if (output != buf) + free (output); + if (len > INT_MAX) { errno = EOVERFLOW; diff --git a/lib/vfprintf.c b/lib/vfprintf.c index 6e3d595f8..4b599b124 100644 --- a/lib/vfprintf.c +++ b/lib/vfprintf.c @@ -1,5 +1,5 @@ /* Formatted output to a stream. - Copyright (C) 2004, 2006-2008 Free Software Foundation, Inc. + Copyright (C) 2004, 2006-2009 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -60,6 +60,9 @@ vfprintf (FILE *fp, const char *format, va_list args) return -1; } + if (output != buf) + free (output); + if (len > INT_MAX) { errno = EOVERFLOW;