diff options
author | Chris Liddell <chris.liddell@artifex.com> | 2022-06-30 09:25:14 +0100 |
---|---|---|
committer | Werner Lemberg <wl@gnu.org> | 2022-07-03 06:58:23 +0200 |
commit | 1a242558be670626ed2ec62efb1909c000b2cae7 (patch) | |
tree | 3375d955305a541f9793961fd629838c1382b8ce | |
parent | 55a97b0cb133b7a5dc28dfabec77a1b9f742c301 (diff) | |
download | freetype2-1a242558be670626ed2ec62efb1909c000b2cae7.tar.gz |
[base] Improve error handling in `FT_GlyphLoader_CheckPoints`.
If `FT_GlyphLoader_CreateExtra` returns an error (and a couple of other
places), `FT_GlyphLoader_CheckPoints` would propagate the error immediately,
rather than cleaning up the partially set up `FT_GlyphLoader`. As a
consequence, a subsequent attempt to create a glyph could result in a crash.
* src/base/ftgloadr.c (FT_GlyphLoader_CheckPoints): Ensure all the error
conditions exits are consistent, eventually calling `FT_GlyphLoader_Reset`.
-rw-r--r-- | src/base/ftgloadr.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/base/ftgloadr.c b/src/base/ftgloadr.c index f05abdee8..90cc09c02 100644 --- a/src/base/ftgloadr.c +++ b/src/base/ftgloadr.c @@ -217,7 +217,7 @@ error = FT_GlyphLoader_CreateExtra( loader ); if ( error ) - return error; + goto Exit; /* check points & tags */ new_max = (FT_UInt)base->n_points + (FT_UInt)current->n_points + @@ -229,7 +229,10 @@ new_max = FT_PAD_CEIL( new_max, 8 ); if ( new_max > FT_OUTLINE_POINTS_MAX ) - return FT_THROW( Array_Too_Large ); + { + error = FT_THROW( Array_Too_Large ); + goto Exit; + } if ( FT_RENEW_ARRAY( base->points, old_max, new_max ) || FT_RENEW_ARRAY( base->tags, old_max, new_max ) ) @@ -254,7 +257,7 @@ error = FT_GlyphLoader_CreateExtra( loader ); if ( error ) - return error; + goto Exit; /* check contours */ old_max = loader->max_contours; @@ -265,7 +268,10 @@ new_max = FT_PAD_CEIL( new_max, 4 ); if ( new_max > FT_OUTLINE_CONTOURS_MAX ) - return FT_THROW( Array_Too_Large ); + { + error = FT_THROW( Array_Too_Large ); + goto Exit; + } if ( FT_RENEW_ARRAY( base->contours, old_max, new_max ) ) goto Exit; |