[util] Fix leak of an hb_font_t
diff --git a/util/font-options.hh b/util/font-options.hh
index 0f13ddd..fa1cffa 100644
--- a/util/font-options.hh
+++ b/util/font-options.hh
@@ -83,6 +83,7 @@
void
font_options_t::post_parse (GError **error)
{
+ assert (!font);
font = hb_font_create (face);
if (font_size_x == FONT_SIZE_UPEM)
@@ -272,7 +273,8 @@
"font",
"Font-instance options:",
"Options for the font instance",
- this);
+ this,
+ false /* We add below. */);
const gchar *variations_help = "Comma-separated list of font variations\n"
"\n"
diff --git a/util/options.hh b/util/options.hh
index acb341f..790650b 100644
--- a/util/options.hh
+++ b/util/options.hh
@@ -110,12 +110,14 @@
const gchar *name,
const gchar *description,
const gchar *help_description,
- Type *closure)
+ Type *closure,
+ bool add_parse_hooks = true)
{
GOptionGroup *group = g_option_group_new (name, description, help_description,
static_cast<gpointer>(closure), nullptr);
g_option_group_add_entries (group, entries);
- g_option_group_set_parse_hooks (group, nullptr, post_parse<Type>);
+ if (add_parse_hooks)
+ g_option_group_set_parse_hooks (group, nullptr, post_parse<Type>);
g_option_context_add_group (context, group);
}