[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[freetype2] master 59320b2d3: [cff] Fix leak of cmap data
From: |
Werner Lemberg |
Subject: |
[freetype2] master 59320b2d3: [cff] Fix leak of cmap data |
Date: |
Thu, 5 Dec 2024 10:01:45 -0500 (EST) |
branch: master
commit 59320b2d3c2584ac01914ed0deff64bcc8fb23b2
Author: Ben Wagner <bungeman@gmail.com>
Commit: Ben Wagner <bungeman@gmail.com>
[cff] Fix leak of cmap data
When `sfnt->load_face` succeeds it has already loaded any (optional)
cmap data. As a result, a subsequent call to `sfnt->load_cmap` will
overwrite the cmap data pointer with a new copy of the data but not free
the old, leading to a leak.
This is a fix for "* src/cff/cffobjs.c (cff_face_init): Better handling
of Type0 fonts.". This still allows the cmap to be missing but avoids
the leak by only calling `sfnt->load_cmap` when there is no `head`
table (the font data is not being loaded as OpenType/CFF).
* src/cff/cffobjs.c (cff_face_init): Fix leak
Fixes: #1306
---
src/cff/cffobjs.c | 18 ++++++++++--------
1 file changed, 10 insertions(+), 8 deletions(-)
diff --git a/src/cff/cffobjs.c b/src/cff/cffobjs.c
index dd4e82122..77dce2818 100644
--- a/src/cff/cffobjs.c
+++ b/src/cff/cffobjs.c
@@ -537,8 +537,8 @@
sfnt_format = 1;
- /* now, the font can be either an OpenType/CFF font, or an SVG CEF */
- /* font; in the latter case it doesn't have a `head' table */
+ /* the font may be OpenType/CFF, SVG CEF, or sfnt/CFF; a `head' table */
+ /* implies OpenType/CFF, otherwise just look for an optional cmap */
error = face->goto_table( face, TTAG_head, stream, 0 );
if ( !error )
{
@@ -550,13 +550,15 @@
if ( error )
goto Exit;
}
+ else
+ {
+ /* load the `cmap' table explicitly */
+ error = sfnt->load_cmap( face, stream );
- /* load the `cmap' table explicitly */
- error = sfnt->load_cmap( face, stream );
-
- /* this may fail because CID-keyed fonts don't have a cmap */
- if ( FT_ERR_NEQ( error, Table_Missing ) && FT_ERR_NEQ( error, Ok ) )
- goto Exit;
+ /* this may fail because CID-keyed fonts don't have a cmap */
+ if ( FT_ERR_NEQ( error, Table_Missing ) && FT_ERR_NEQ( error, Ok ) )
+ goto Exit;
+ }
/* now load the CFF part of the file; */
/* give priority to CFF2 */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [freetype2] master 59320b2d3: [cff] Fix leak of cmap data,
Werner Lemberg <=