[PATCH] Fix memory leak in printf_positional

Paul Eggert eggert@cs.ucla.edu
Wed Aug 26 06:41:00 GMT 2015


* stdio-common/vfprintf.c (printf_positional):
Free temporary data allocated via malloc.
---
 ChangeLog               | 4 ++++
 stdio-common/vfprintf.c | 2 ++
 2 files changed, 6 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index 4ee7c94..bd6d027 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2015-08-25  Paul Eggert  <eggert@cs.ucla.edu>
 
+	Fix memory leak in printf_positional
+	* stdio-common/vfprintf.c (printf_positional):
+	Free temporary data allocated via malloc.
+
 	Fix memory leak in _nl_load_domain
 	* intl/loadmsgcat.c (_nl_load_domain):
 	Free data after a read failure.
diff --git a/stdio-common/vfprintf.c b/stdio-common/vfprintf.c
index 0592e70..9d5406a 100644
--- a/stdio-common/vfprintf.c
+++ b/stdio-common/vfprintf.c
@@ -2091,6 +2091,8 @@ printf_positional (_IO_FILE *s, const CHAR_T *format, int readonly_format,
 		 - specs[nspecs_done].end_of_fmt);
     }
  all_done:
+  if (__glibc_unlikely (args_malloced != NULL))
+    free (args_malloced);
   if (__glibc_unlikely (workstart != NULL))
     free (workstart);
   return done;
-- 
2.1.0



More information about the Libc-alpha mailing list