From bc6ecaa2629d065583ffa86ebed4dcea53505f42 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Wed, 1 Jun 2022 09:19:11 -0600 Subject: [PATCH] [font-funcs] Handle case of null func but non-null destroy or user-data --- src/hb-font.cc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/hb-font.cc b/src/hb-font.cc index fb2631db8..8c4888561 100644 --- a/src/hb-font.cc +++ b/src/hb-font.cc @@ -832,6 +832,14 @@ hb_font_funcs_set_##name##_func (hb_font_funcs_t *ffuncs, \ { \ if (hb_object_is_immutable (ffuncs)) \ goto fail; \ + \ + if (!func) \ + { \ + if (destroy) \ + destroy (user_data); \ + destroy = nullptr; \ + user_data = nullptr; \ + } \ \ if (ffuncs->destroy && ffuncs->destroy->name) \ ffuncs->destroy->name (!ffuncs->user_data ? nullptr : ffuncs->user_data->name); \