changeset 107257:d8f04397b77a

Fix use of unitialized memory. * charset.c (load_charset_map_from_file) (load_charset_map_from_vector): Zero out allocated charset_map_entries before using them.
author Chong Yidong <cyd@stupidchicken.com>
date Sun, 28 Feb 2010 09:19:31 -0500
parents 122dff72a8ee
children 4f44eaade84e d8c6d8e3da50
files src/ChangeLog src/charset.c
diffstat 2 files changed, 10 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog	Sun Feb 28 12:36:39 2010 +0100
+++ b/src/ChangeLog	Sun Feb 28 09:19:31 2010 -0500
@@ -1,3 +1,9 @@
+2010-02-28  Chong Yidong  <cyd@stupidchicken.com>
+
+	* charset.c (load_charset_map_from_file)
+	(load_charset_map_from_vector): Zero out allocated
+	charset_map_entries before using them.
+
 2010-02-27  Andreas Schwab  <schwab@linux-m68k.org>
 
 	* w32uniscribe.c (uniscribe_check_otf): Fix length check.
--- a/src/charset.c	Sun Feb 28 12:36:39 2010 +0100
+++ b/src/charset.c	Sun Feb 28 09:19:31 2010 -0500
@@ -531,6 +531,7 @@
   SAFE_ALLOCA (head, struct charset_map_entries *,
 	       sizeof (struct charset_map_entries));
   entries = head;
+  bzero (entries, sizeof (struct charset_map_entries));
 
   n_entries = 0;
   eof = 0;
@@ -557,6 +558,7 @@
 	  SAFE_ALLOCA (entries->next, struct charset_map_entries *,
 		       sizeof (struct charset_map_entries));
 	  entries = entries->next;
+	  bzero (entries, sizeof (struct charset_map_entries));
 	}
       idx = n_entries % 0x10000;
       entries->entry[idx].from = from;
@@ -596,6 +598,7 @@
   SAFE_ALLOCA (head, struct charset_map_entries *,
 	       sizeof (struct charset_map_entries));
   entries = head;
+  bzero (entries, sizeof (struct charset_map_entries));
 
   n_entries = 0;
   for (i = 0; i < len; i += 2)
@@ -632,6 +635,7 @@
 	  SAFE_ALLOCA (entries->next, struct charset_map_entries *,
 		       sizeof (struct charset_map_entries));
 	  entries = entries->next;
+	  bzero (entries, sizeof (struct charset_map_entries));
 	}
       idx = n_entries % 0x10000;
       entries->entry[idx].from = from;