[pango/matthiasc/for-main] Avoid a crash
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pango/matthiasc/for-main] Avoid a crash
- Date: Thu, 2 Sep 2021 01:14:58 +0000 (UTC)
commit 21a0ba66b1e670b8ce858ae285384f69345508af
Author: Matthias Clasen <mclasen redhat com>
Date: Wed Sep 1 21:13:54 2021 -0400
Avoid a crash
I was carelessly not initializing prev to NULL.
pango/itemize.c | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
---
diff --git a/pango/itemize.c b/pango/itemize.c
index 29a1cdff..bd339633 100644
--- a/pango/itemize.c
+++ b/pango/itemize.c
@@ -1056,15 +1056,21 @@ collect_font_scale (PangoContext *context,
entry->attr = attr;
*stack = g_list_prepend (*stack, entry);
- hb_font = pango_font_get_hb_font (prev->analysis.font);
- hb_font_get_scale (hb_font, NULL, &y_scale);
+ if (prev)
+ {
+ hb_font = pango_font_get_hb_font (prev->analysis.font);
+ hb_font_get_scale (hb_font, NULL, &y_scale);
+ }
+ else
+ hb_font = NULL;
switch (((PangoAttrInt *)attr)->value)
{
case PANGO_FONT_SCALE_NONE:
break;
case PANGO_FONT_SCALE_SUPERSCRIPT:
- if (hb_ot_metrics_get_position (hb_font,
+ if (hb_font &&
+ hb_ot_metrics_get_position (hb_font,
HB_OT_METRICS_TAG_SUPERSCRIPT_EM_Y_SIZE,
&y_size))
entry->scale = y_size / (double) y_scale;
@@ -1072,7 +1078,8 @@ collect_font_scale (PangoContext *context,
entry->scale = 1 / 1.2;
break;
case PANGO_FONT_SCALE_SUBSCRIPT:
- if (hb_ot_metrics_get_position (hb_font,
+ if (hb_font &&
+ hb_ot_metrics_get_position (hb_font,
HB_OT_METRICS_TAG_SUBSCRIPT_EM_Y_SIZE,
&y_size))
entry->scale = y_size / (double) y_scale;
@@ -1139,7 +1146,7 @@ static void
apply_font_scale (PangoContext *context,
GList *items)
{
- PangoItem *prev;
+ PangoItem *prev = NULL;
GList *stack = NULL;
for (GList *l = items; l; l = l->next)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]