# HG changeset patch # User Joel E. Denny # Date 1260868059 -3600 # Node ID eccd5d7c7a6915fff17d64338faa0d6ff02cf527 # Parent e962488c88abca9de07f0c7aba06feb04ab4752c *printf: Fix memory leak. diff --git a/ChangeLog b/ChangeLog --- 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 --- a/lib/dprintf.c +++ b/lib/dprintf.c @@ -57,6 +57,9 @@ return -1; } + if (output != buf) + free (output); + if (len > INT_MAX) { errno = EOVERFLOW; diff --git a/lib/fprintf.c b/lib/fprintf.c --- 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 @@ return -1; } + if (output != buf) + free (output); + if (len > INT_MAX) { errno = EOVERFLOW; diff --git a/lib/vdprintf.c b/lib/vdprintf.c --- a/lib/vdprintf.c +++ b/lib/vdprintf.c @@ -54,6 +54,9 @@ return -1; } + if (output != buf) + free (output); + if (len > INT_MAX) { errno = EOVERFLOW; diff --git a/lib/vfprintf.c b/lib/vfprintf.c --- 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 @@ return -1; } + if (output != buf) + free (output); + if (len > INT_MAX) { errno = EOVERFLOW;