freetype2/src
Ben Wagner 13983b058e [base] Fix leak of internal stream marked external.
`open_face_from_buffer` allocates a new `FT_Stream` to pass to
`ft_open_face_internal`.  Because this is an `FT_OPEN_STREAM`,
`ft_open_face_internal` will mark this as an 'external stream', which the
caller must free.  However, `open_face_from_buffer` cannot directly free it
because the stream must last as long as the face.  There is currently an
attempt at this by clearing the 'external stream' bit after
`open_face_from_buffer` returns successfully.  However, this is too late as
the original stream may have already been closed and the stream on the face
may not be the same stream as originally passed.

It is tempting to use `FT_OPEN_MEMORY` and let `ft_open_face_internal`
create the stream internally.  However, with this method there is no means
to pass through a 'close' function to the created stream to free the
underlying data, which must be owned by the stream.

A possibility is to check on success if the stream of the face is the same
as the original stream.  If it is then unset the external flag.  If not,
then free the original stream.  Unfortunately, while no current
implementation does so, it is possible that the face still has the original
stream somewhere other than as the `FT_FaceRec::stream`.  The stream needs
to remain available for the life of the face or until it is closed,
whichever comes earlier.

The approach taken here is to let the stream own itself.  When the stream is
closed it will free itself.

* src/base/ftobjs.c (memory_stream_close): Free `stream`.
(open_face_from_buffer): Simplify error handling, since
`ft_open_face_internal` always closes `args.stream` on any error.

Fixes: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=54930
2023-01-17 08:48:33 +01:00
..
autofit sr/*.c: Various minor fixes. 2023-01-16 16:38:56 +01:00
base [base] Fix leak of internal stream marked external. 2023-01-17 08:48:33 +01:00
bdf [bdf, pfr, psnames] Accelarate charmap searches. 2022-11-06 13:12:47 -05:00
bzip2 Whitespace. 2022-04-01 08:50:33 +02:00
cache * src/cache/ftccmap.c (FTC_CMapCache_Lookup): Avoid `FT_Set_Charmap`. 2022-10-03 17:13:30 +00:00
cff [cff, truetype] Simplify SVG metrics scaling. 2022-10-21 12:14:52 +00:00
cid Update all copyright notices. 2022-01-11 10:54:10 +01:00
dlg Update all copyright notices. 2022-01-11 10:54:10 +01:00
gxvalid sr/*.c: Various minor fixes. 2023-01-16 16:38:56 +01:00
gzip sr/*.c: Various minor fixes. 2023-01-16 16:38:56 +01:00
lzw * src/lzw/ftzopen.c (ft_lzwstate_stack_grow): Cosmetic macro change. 2022-06-11 23:47:19 -04:00
otvalid * src/otvalid/otvgsub.c (otv_SingleSubst_validate): Fix format 1 handling. 2022-09-15 09:14:06 +02:00
pcf Comments added. 2022-11-18 14:03:19 +00:00
pfr * src/pfr/pfrsbit.c (pfr_lookup_bitmap_data): Accelerate the search. 2022-11-07 21:36:32 -05:00
psaux [psaux] Delay the upem validity assertion. 2022-12-20 16:38:39 +00:00
pshinter Fix clang++ warnings. 2022-03-31 07:49:35 +02:00
psnames [bdf, pfr, psnames] Accelarate charmap searches. 2022-11-06 13:12:47 -05:00
raster Whitespace. 2022-04-01 08:50:33 +02:00
sdf [sdf, sfnt] Handle minor compiler warnings. 2022-12-13 09:53:26 +01:00
sfnt sr/*.c: Various minor fixes. 2023-01-16 16:38:56 +01:00
smooth [smooth] Fix GCC LTO crashes on Windows. 2022-06-10 11:34:56 -04:00
svg * src/svg/ftsvg.c (ft_svg_property_set): Disallow NULL pointers. 2022-01-23 19:05:15 +01:00
tools * src/tools/*.py: Migrate to Python 3. 2022-09-28 22:35:49 -04:00
truetype [sfnt] Remove temporary runtime flag for variable 'COLR' v1. 2023-01-16 14:02:36 +01:00
type1 * src/type1/t1afm.c (T1_Read_PFM): Set charmaps directly. 2022-10-03 19:18:48 -04:00
type42 Whitespace. 2022-04-01 08:50:33 +02:00
winfonts Whitespace. 2022-04-01 08:50:33 +02:00