freetype/src/base
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
..
ftadvanc.c Update all copyright notices. 2022-01-11 10:54:10 +01:00
ftbase.c Update all copyright notices. 2022-01-11 10:54:10 +01:00
ftbase.h Add FT_Glyph support for OT-SVG glyphs. 2022-01-20 16:45:18 +00:00
ftbbox.c Update all copyright notices. 2022-01-11 10:54:10 +01:00
ftbdf.c Update all copyright notices. 2022-01-11 10:54:10 +01:00
ftbitmap.c [base] Clean up the bitmap flow control. 2022-09-22 20:40:21 -04:00
ftcalc.c [base] Round values in FT_MulAdd_Fix. 2022-07-01 14:01:08 +02:00
ftcid.c Update all copyright notices. 2022-01-11 10:54:10 +01:00
ftcolor.c Update all copyright notices. 2022-01-11 10:54:10 +01:00
ftdbgmem.c * src/base/ftdbgmem.c (ft_mem_source_compare): Add FT_COMPARE_DEF. 2022-11-22 22:34:41 -05:00
ftdebug.c Update all copyright notices. 2022-01-11 10:54:10 +01:00
fterrors.c Update all copyright notices. 2022-01-11 10:54:10 +01:00
ftfntfmt.c Update all copyright notices. 2022-01-11 10:54:10 +01:00
ftfstype.c Update all copyright notices. 2022-01-11 10:54:10 +01:00
ftgasp.c Update all copyright notices. 2022-01-11 10:54:10 +01:00
ftgloadr.c [base] Build outlines in amortized constant time. 2022-07-23 23:30:22 +02:00
ftglyph.c * src/base/ftglyph.c (FT_Get_Glyph): Set *aglyph to NULL in case of error. 2022-07-29 22:57:18 +02:00
ftgxval.c Update all copyright notices. 2022-01-11 10:54:10 +01:00
fthash.c * src/base/fthash.c (hash_insert): Avoid unnecessary zeroing. 2022-01-14 18:22:23 +00:00
ftinit.c Update all copyright notices. 2022-01-11 10:54:10 +01:00
ftlcdfil.c Update all copyright notices. 2022-01-11 10:54:10 +01:00
ftmac.c [build] fix for make multi 2022-11-08 14:23:37 +09:00
ftmm.c Update all copyright notices. 2022-01-11 10:54:10 +01:00
ftobjs.c [base] Fix leak of internal stream marked external. 2023-01-17 08:48:33 +01:00
ftotval.c Update all copyright notices. 2022-01-11 10:54:10 +01:00
ftoutln.c Update all copyright notices. 2022-01-11 10:54:10 +01:00
ftpatent.c Update all copyright notices. 2022-01-11 10:54:10 +01:00
ftpfr.c Update all copyright notices. 2022-01-11 10:54:10 +01:00
ftpsprop.c Update all copyright notices. 2022-01-11 10:54:10 +01:00
ftrfork.c Whitespace. 2022-04-01 08:50:33 +02:00
ftsnames.c Update all copyright notices. 2022-01-11 10:54:10 +01:00
ftstream.c [stream] Fix reading s32 when long is s64 2022-06-18 12:58:23 -04:00
ftstroke.c Update all copyright notices. 2022-01-11 10:54:10 +01:00
ftsynth.c * src/base/ftsynth.c (FT_GlyphSlot_Slant): New API with custom slant. 2022-10-16 22:10:19 -04:00
ftsystem.c Update all copyright notices. 2022-01-11 10:54:10 +01:00
fttrigon.c Update all copyright notices. 2022-01-11 10:54:10 +01:00
fttype1.c Update all copyright notices. 2022-01-11 10:54:10 +01:00
ftutil.c Update all copyright notices. 2022-01-11 10:54:10 +01:00
ftver.rc * src/base/ftver.rc: Explicitly use UTF-16. 2022-08-26 22:24:02 -04:00
ftwinfnt.c Update all copyright notices. 2022-01-11 10:54:10 +01:00
md5.c * src/base/md5.c: Updated to recent version. 2016-06-16 06:17:54 +02:00
md5.h * src/base/md5.c, src/base/md5.h: Updated to recent version. 2013-10-22 01:10:10 +02:00
rules.mk Update all copyright notices. 2022-01-11 10:54:10 +01:00