[unicode] Destroy user_data in set_funcs fail paths
This is what the font_funcs / draw_funcs do.
This commit is contained in:
parent
56d6b6992b
commit
527823ccac
|
@ -377,7 +377,14 @@ hb_unicode_funcs_set_##name##_func (hb_unicode_funcs_t *ufuncs, \
|
||||||
hb_destroy_func_t destroy) \
|
hb_destroy_func_t destroy) \
|
||||||
{ \
|
{ \
|
||||||
if (hb_object_is_immutable (ufuncs)) \
|
if (hb_object_is_immutable (ufuncs)) \
|
||||||
return; \
|
goto fail; \
|
||||||
|
\
|
||||||
|
if (!func && destroy) \
|
||||||
|
{ \
|
||||||
|
destroy (user_data); \
|
||||||
|
destroy = nullptr; \
|
||||||
|
user_data = nullptr; \
|
||||||
|
} \
|
||||||
\
|
\
|
||||||
if (ufuncs->destroy.name) \
|
if (ufuncs->destroy.name) \
|
||||||
ufuncs->destroy.name (ufuncs->user_data.name); \
|
ufuncs->destroy.name (ufuncs->user_data.name); \
|
||||||
|
@ -391,6 +398,11 @@ hb_unicode_funcs_set_##name##_func (hb_unicode_funcs_t *ufuncs, \
|
||||||
ufuncs->user_data.name = ufuncs->parent->user_data.name; \
|
ufuncs->user_data.name = ufuncs->parent->user_data.name; \
|
||||||
ufuncs->destroy.name = nullptr; \
|
ufuncs->destroy.name = nullptr; \
|
||||||
} \
|
} \
|
||||||
|
return; \
|
||||||
|
\
|
||||||
|
fail: \
|
||||||
|
if (destroy) \
|
||||||
|
destroy (user_data); \
|
||||||
}
|
}
|
||||||
|
|
||||||
HB_UNICODE_FUNCS_IMPLEMENT_CALLBACKS
|
HB_UNICODE_FUNCS_IMPLEMENT_CALLBACKS
|
||||||
|
|
|
@ -754,9 +754,9 @@ test_unicode_setters (void)
|
||||||
/* Since uf is immutable now, the following setter should do nothing. */
|
/* Since uf is immutable now, the following setter should do nothing. */
|
||||||
p->func_setter (uf, (get_func_t) a_is_for_arabic_get_script, &data[1], free_up);
|
p->func_setter (uf, (get_func_t) a_is_for_arabic_get_script, &data[1], free_up);
|
||||||
|
|
||||||
g_assert (data[0].freed && !data[1].freed);
|
g_assert (data[0].freed && data[1].freed);
|
||||||
hb_unicode_funcs_destroy (uf);
|
hb_unicode_funcs_destroy (uf);
|
||||||
g_assert (data[0].freed && !data[1].freed);
|
g_assert (data[0].freed && data[1].freed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue