Commit 4c60bd916cd487b9ee90b561ecfa4011d443c68c

Suzuki, Toshiya (鈴木俊哉) 2008-08-19T15:35:44

* Fix FT_Stream_New() to initialize stream always

diff --git a/ChangeLog b/ChangeLog
index 00a144d..617f8ec 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2008-08-19  suzuki toshiya <mpsuzuki@hiroshima-u.ac.jp>
+
+	* src/base/ftobjs.c (FT_Stream_New): Initialize *astream
+	always, even if passed library or arguments are invalid.
+	This fixes a bug that uninitialized stream is freed when
+	an invalid library handle is passed. Originally proposed
+	by Mike Fabian, 2008/08/18 on freetype-devel.
+	(FT_Open_Face): Ditto (stream).
+	(load_face_in_embedded_rfork): Ditto (stream2).
+
 2008-08-18  suzuki toshiya <mpsuzuki@hiroshima-u.ac.jp>
 
 	* src/base/ftmac.c: Add a fallback to guess the availability of the
diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c
index 8208e2a..76ebfe4 100644
--- a/src/base/ftobjs.c
+++ b/src/base/ftobjs.c
@@ -128,13 +128,14 @@
     FT_Stream  stream;
 
 
+    *astream = 0;
+
     if ( !library )
       return FT_Err_Invalid_Library_Handle;
 
     if ( !args )
       return FT_Err_Invalid_Argument;
 
-    *astream = 0;
     memory   = library->memory;
 
     if ( FT_NEW( stream ) )
@@ -1600,7 +1601,7 @@
     FT_Error   errors[FT_RACCESS_N_RULES];
 
     FT_Open_Args  args2;
-    FT_Stream     stream2;
+    FT_Stream     stream2 = 0;
 
 
     FT_Raccess_Guess( library, stream,
@@ -1713,7 +1714,7 @@
     FT_Error     error;
     FT_Driver    driver;
     FT_Memory    memory;
-    FT_Stream    stream;
+    FT_Stream    stream = 0;
     FT_Face      face = 0;
     FT_ListNode  node = 0;
     FT_Bool      external_stream;