This is the mail archive of the libc-hacker@sources.redhat.com mailing list for the glibc project.

Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix __register_printf_function


Hi!

Using uninited memory is bad idea, sorry.

2003-04-05  Jakub Jelinek  <jakub at redhat dot com>

	* stdio-common/reg-printf.c (__register_printf_function): Calloc
	instead of malloc __printf_arginfo_table and __printf_function_table.
	Reported by John Reiser <jreiser at BitWagon dot com>.

--- libc/stdio-common/reg-printf.c.jj	2002-11-05 17:12:55.000000000 -0500
+++ libc/stdio-common/reg-printf.c	2003-04-04 19:04:45.000000000 -0500
@@ -46,7 +46,7 @@ __register_printf_function (spec, conver
   if (__printf_function_table == NULL)
     {
       __printf_arginfo_table = (printf_arginfo_function **)
-	malloc ((UCHAR_MAX + 1) * sizeof (void *) * 2);
+	calloc ((UCHAR_MAX + 1), sizeof (void *) * 2);
       if (__printf_arginfo_table == NULL)
 	return -1;
       __printf_function_table = (printf_function **)

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]