FT_Open_Face: Improve external stream handling.
If the font's `clazz->init_face' function wants to swap to new stream, handling of whether original stream was external could result to either memory leak or double free. Mark externality into face flags before calling `init_face' such that the clazz can handle external streams properly. * src/base/ftobjs.c (FT_Open_Face): Move code to set FT_FACE_FLAG_EXTERNAL_STREAM to... (open_face): This function.
This commit is contained in:
parent
bcd8c0b0eb
commit
bd3849e7de
14
ChangeLog
14
ChangeLog
|
@ -1,3 +1,17 @@
|
|||
2013-08-27 Behdad Esfahbod <behdad@google.com>
|
||||
|
||||
FT_Open_Face: Improve external stream handling.
|
||||
|
||||
If the font's `clazz->init_face' function wants to swap to new
|
||||
stream, handling of whether original stream was external could
|
||||
result to either memory leak or double free. Mark externality into
|
||||
face flags before calling `init_face' such that the clazz can handle
|
||||
external streams properly.
|
||||
|
||||
* src/base/ftobjs.c (FT_Open_Face): Move code to set
|
||||
FT_FACE_FLAG_EXTERNAL_STREAM to...
|
||||
(open_face): This function.
|
||||
|
||||
2013-08-27 Werner Lemberg <wl@gnu.org>
|
||||
|
||||
Remove `FT_SqrtFixed' function.
|
||||
|
|
|
@ -1134,6 +1134,7 @@
|
|||
static FT_Error
|
||||
open_face( FT_Driver driver,
|
||||
FT_Stream stream,
|
||||
FT_Bool external_stream,
|
||||
FT_Long face_index,
|
||||
FT_Int num_params,
|
||||
FT_Parameter* params,
|
||||
|
@ -1157,6 +1158,11 @@
|
|||
face->memory = memory;
|
||||
face->stream = stream;
|
||||
|
||||
/* set the FT_FACE_FLAG_EXTERNAL_STREAM bit for FT_Done_Face */
|
||||
if ( external_stream )
|
||||
face->face_flags |= FT_FACE_FLAG_EXTERNAL_STREAM;
|
||||
|
||||
|
||||
if ( FT_NEW( internal ) )
|
||||
goto Fail;
|
||||
|
||||
|
@ -2069,7 +2075,7 @@
|
|||
params = args->params;
|
||||
}
|
||||
|
||||
error = open_face( driver, stream, face_index,
|
||||
error = open_face( driver, stream, external_stream, face_index,
|
||||
num_params, params, &face );
|
||||
if ( !error )
|
||||
goto Success;
|
||||
|
@ -2105,7 +2111,7 @@
|
|||
params = args->params;
|
||||
}
|
||||
|
||||
error = open_face( driver, stream, face_index,
|
||||
error = open_face( driver, stream, external_stream, face_index,
|
||||
num_params, params, &face );
|
||||
if ( !error )
|
||||
goto Success;
|
||||
|
@ -2174,10 +2180,6 @@
|
|||
Success:
|
||||
FT_TRACE4(( "FT_Open_Face: New face object, adding to list\n" ));
|
||||
|
||||
/* set the FT_FACE_FLAG_EXTERNAL_STREAM bit for FT_Done_Face */
|
||||
if ( external_stream )
|
||||
face->face_flags |= FT_FACE_FLAG_EXTERNAL_STREAM;
|
||||
|
||||
/* add the face object to its driver's list */
|
||||
if ( FT_NEW( node ) )
|
||||
goto Fail;
|
||||
|
|
Loading…
Reference in New Issue