*printf: Fix memory leak.
authorJoel E. Denny <jdenny@clemson.edu>
Tue, 15 Dec 2009 09:07:39 +0000 (10:07 +0100)
committerBruno Haible <bruno@clisp.org>
Tue, 15 Dec 2009 09:18:30 +0000 (10:18 +0100)
ChangeLog
lib/dprintf.c
lib/fprintf.c
lib/vdprintf.c
lib/vfprintf.c

index 2756f67..0f42ccf 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2009-12-15  Joel E. Denny  <jdenny@clemson.edu>
+            Bruno Haible  <bruno@clisp.org>
+
+       *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  <ebb9@byu.net>
 
        accept4: adjust module dependencies
index 70f992f..99ee6af 100644 (file)
@@ -57,6 +57,9 @@ dprintf (int fd, const char *format, ...)
       return -1;
     }
 
+  if (output != buf)
+    free (output);
+
   if (len > INT_MAX)
     {
       errno = EOVERFLOW;
index eb1cf8e..dc8fcfb 100644 (file)
@@ -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;
index 2b0da8a..77c8c6e 100644 (file)
@@ -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;
index 6e3d595..4b599b1 100644 (file)
@@ -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;