summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2022-09-26 20:22:44 -0400
committerMatthias Clasen <mclasen@redhat.com>2022-09-26 20:45:40 -0400
commitb7666befa248ea0cb9716b8e3c3e6b43e9f15ccf (patch)
tree784a7c1835560815d9eaa83eb330579a8919ac8a
parentf2add41dadacd7cb2df804a2e7faa670c8db69ee (diff)
downloadpango-b7666befa248ea0cb9716b8e3c3e6b43e9f15ccf.tar.gz
fonts: Handle lack of fonts
Make pango_font_get_scale_factors return 1 if the font is NULL. This avoids crashes in situations where we cannot find any fonts. Fixes: #701
-rw-r--r--pango/fonts.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/pango/fonts.c b/pango/fonts.c
index e7bd4780..47671424 100644
--- a/pango/fonts.c
+++ b/pango/fonts.c
@@ -2871,5 +2871,11 @@ pango_font_get_scale_factors (PangoFont *font,
double *x_scale,
double *y_scale)
{
+ if (G_UNLIKELY (!font))
+ {
+ *x_scale = *y_scale = .1;
+ return;
+ }
+
PANGO_FONT_GET_CLASS_PRIVATE (font)->get_scale_factors (font, x_scale, y_scale);
}