]> granicus.if.org Git - graphviz/commit
Pango plugin gv_get_ps_fontlist: postpone 'family_name' allocation
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Sun, 31 Jul 2022 16:26:41 +0000 (09:26 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Sat, 6 Aug 2022 01:01:38 +0000 (18:01 -0700)
commit500dd0528f8767c29f37f0b54bc103036b7ca00c
tree7bb96a997e55296de9c05b43c20baa34fdb6d6d5
parentb00d422b2f1ee18174cbcab7ad9b50cf8ee8c334
Pango plugin gv_get_ps_fontlist: postpone 'family_name' allocation

Rather than allocating this upfront and then potentially needing to free it
later, we can use a string view to postpone the allocation to when we know it is
actually needed. This works because the lifetime of the backing memory extends
until the call to `g_free(families)`. This also fixes the lack of allocation
failure checks; instead of `strdup` we now call `strview_str` that gracefully
exits on allocation failure.
plugin/pango/gvgetfontlist_pango.c