[ft] Better handle allocation failures
Fixes https://github.com/harfbuzz/harfbuzz/issues/2513
This commit is contained in:
parent
26111a11ad
commit
26b9670d99
15
src/hb-ft.cc
15
src/hb-ft.cc
|
@ -92,9 +92,7 @@ static hb_ft_font_t *
|
||||||
_hb_ft_font_create (FT_Face ft_face, bool symbol, bool unref)
|
_hb_ft_font_create (FT_Face ft_face, bool symbol, bool unref)
|
||||||
{
|
{
|
||||||
hb_ft_font_t *ft_font = (hb_ft_font_t *) calloc (1, sizeof (hb_ft_font_t));
|
hb_ft_font_t *ft_font = (hb_ft_font_t *) calloc (1, sizeof (hb_ft_font_t));
|
||||||
|
if (unlikely (!ft_font)) return nullptr;
|
||||||
if (unlikely (!ft_font))
|
|
||||||
return nullptr;
|
|
||||||
|
|
||||||
ft_font->lock.init ();
|
ft_font->lock.init ();
|
||||||
ft_font->ft_face = ft_face;
|
ft_font->ft_face = ft_face;
|
||||||
|
@ -120,9 +118,6 @@ _hb_ft_font_destroy (void *data)
|
||||||
{
|
{
|
||||||
hb_ft_font_t *ft_font = (hb_ft_font_t *) data;
|
hb_ft_font_t *ft_font = (hb_ft_font_t *) data;
|
||||||
|
|
||||||
if (unlikely (!ft_font))
|
|
||||||
return;
|
|
||||||
|
|
||||||
ft_font->advance_cache.fini ();
|
ft_font->advance_cache.fini ();
|
||||||
|
|
||||||
if (ft_font->unref)
|
if (ft_font->unref)
|
||||||
|
@ -623,9 +618,12 @@ _hb_ft_font_set_funcs (hb_font_t *font, FT_Face ft_face, bool unref)
|
||||||
{
|
{
|
||||||
bool symbol = ft_face->charmap && ft_face->charmap->encoding == FT_ENCODING_MS_SYMBOL;
|
bool symbol = ft_face->charmap && ft_face->charmap->encoding == FT_ENCODING_MS_SYMBOL;
|
||||||
|
|
||||||
|
hb_ft_font_t *ft_font = _hb_ft_font_create (ft_face, symbol, unref);
|
||||||
|
if (unlikely (!ft_font)) return;
|
||||||
|
|
||||||
hb_font_set_funcs (font,
|
hb_font_set_funcs (font,
|
||||||
_hb_ft_get_font_funcs (),
|
_hb_ft_get_font_funcs (),
|
||||||
_hb_ft_font_create (ft_face, symbol, unref),
|
ft_font,
|
||||||
_hb_ft_font_destroy);
|
_hb_ft_font_destroy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -833,9 +831,6 @@ hb_ft_font_changed (hb_font_t *font)
|
||||||
|
|
||||||
hb_ft_font_t *ft_font = (hb_ft_font_t *) font->user_data;
|
hb_ft_font_t *ft_font = (hb_ft_font_t *) font->user_data;
|
||||||
|
|
||||||
if (unlikely (!ft_font))
|
|
||||||
return;
|
|
||||||
|
|
||||||
FT_Face ft_face = ft_font->ft_face;
|
FT_Face ft_face = ft_font->ft_face;
|
||||||
|
|
||||||
hb_font_set_scale (font,
|
hb_font_set_scale (font,
|
||||||
|
|
Loading…
Reference in New Issue