Fix an unlikely UAF on the deprecated _set_glyph_func API
Fixes https://github.com/harfbuzz/harfbuzz/issues/2168
diff --git a/src/hb-font.cc b/src/hb-font.cc
index 60fc218..9c732cf 100644
--- a/src/hb-font.cc
+++ b/src/hb-font.cc
@@ -677,7 +677,8 @@
void *user_data, \
hb_destroy_func_t destroy) \
{ \
- if (hb_object_is_immutable (ffuncs)) { \
+ if (hb_object_is_immutable (ffuncs)) \
+ { \
if (destroy) \
destroy (user_data); \
return; \
@@ -2152,6 +2153,13 @@
hb_font_get_glyph_func_t func,
void *user_data, hb_destroy_func_t destroy)
{
+ if (hb_object_is_immutable (ffuncs))
+ {
+ if (destroy)
+ destroy (user_data);
+ return;
+ }
+
hb_font_get_glyph_trampoline_t *trampoline;
trampoline = trampoline_create (func, user_data, destroy);