From 6a281140641872ed0c6d323b06304cca57cdc9e1 Mon Sep 17 00:00:00 2001 From: Tor Lillqvist Date: Wed, 1 Mar 2006 00:26:07 +0000 Subject: Check the font pointer being NULL to avoid crashes for at least one class 2006-03-01 Tor Lillqvist * pango/pango-context.c (update_metrics_from_items): Check the font pointer being NULL to avoid crashes for at least one class of "bad" fonts (those without a Unicode cmap) on Win32. It would probably be better to prune out such fonts already in the enumeration phase. That would require opening (CreateFontIndirect) every font, though, to be able to check with GetFontData() whether there is a Unicode cmap. Don't know how much that would slow down the enumeration. --- ChangeLog | 11 +++++++++++ pango/pango-context.c | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 5c90d825..93467224 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2006-03-01 Tor Lillqvist + + * pango/pango-context.c (update_metrics_from_items): Check the + font pointer being NULL to avoid crashes for at least one class of + "bad" fonts (those without a Unicode cmap) on Win32. It would + probably be better to prune out such fonts already in the + enumeration phase. That would require opening (CreateFontIndirect) + every font, though, to be able to check with GetFontData() whether + there is a Unicode cmap. Don't know how much that would slow down + the enumeration. + 2006-02-28 Tor Lillqvist * pango/pangowin32-private.h (PING) diff --git a/pango/pango-context.c b/pango/pango-context.c index 49db52a9..0e3fb1e5 100644 --- a/pango/pango-context.c +++ b/pango/pango-context.c @@ -1310,7 +1310,7 @@ update_metrics_from_items (PangoFontMetrics *metrics, PangoItem *item = l->data; PangoFont *font = item->analysis.font; - if (g_hash_table_lookup (fonts_seen, font) == NULL) + if (font != NULL && g_hash_table_lookup (fonts_seen, font) == NULL) { PangoFontMetrics *raw_metrics = pango_font_get_metrics (font, language); g_hash_table_insert (fonts_seen, font, font); -- cgit v1.2.1