* Fix FT_Stream_New() to initialize stream always
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
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;