Skip to content

Commit

Permalink
font: Fix double resource leak in font::pango_text
Browse files Browse the repository at this point in the history
The impacted code path is only executed as part of the implementation of
the characters_per_line constraint.

According to the Pango documentation, PangoFontMetrics should be
released using pango_font_metrics_unref(), and PangoFont should be
released using *something* not specified. Existing code, and the
documentation for pango_fontset_get_font(), suggests the answer for the
latter is g_object_unref().
  • Loading branch information
irydacea committed Mar 9, 2021
1 parent 7ed2a7a commit c40232d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions changelog.md
Expand Up @@ -21,6 +21,7 @@
### User interface
* Improved the Load dialog when there are no saved games for the current version, and also when there are corrupted files.
* Re-added the pop-up when there are no saved games at all (issue #5517).
* Fixed resource leak in the Pango text rendering pipeline when using the characters_per_line constraint.
### WML Engine
* Standard Location Filters now support gives_income=yes|no to make it simpler to match villages regardless of owner
### Miscellaneous and Bug Fixes
Expand Down
3 changes: 3 additions & 0 deletions src/font/text.cpp
Expand Up @@ -518,6 +518,9 @@ PangoRectangle pango_text::calculate_size(PangoLayout& layout) const
w *= characters_per_line_;

maximum_width = ceil(pango_units_to_double(w));

pango_font_metrics_unref(m);
g_object_unref(f);
} else {
maximum_width = maximum_width_;
}
Expand Down

0 comments on commit c40232d

Please sign in to comment.