summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBehdad Esfahbod <behdad@gnome.org>2005-11-23 15:19:48 +0000
committerBehdad Esfahbod <behdad@src.gnome.org>2005-11-23 15:19:48 +0000
commita775a8b1b6ddf7b7ca3e5ba649db7d766f99762f (patch)
treecad2b5794f29206d611eed076fe1b6abceebb54d
parent2cd1b4099a4bc48bb2589c52deb11f20c728fb57 (diff)
downloadpango-a775a8b1b6ddf7b7ca3e5ba649db7d766f99762f.tar.gz
Protect against possible division by zeros (#316468, Steve Grubb)
2005-11-23 Behdad Esfahbod <behdad@gnome.org> Protect against possible division by zeros (#316468, Steve Grubb) * pango/pango-context.c (update_metrics_from_items), pango/pango-fontset.c (pango_fontset_real_get_metrics): If count is zero, do not alter approximate_{char,digit}_width. * pango/opentype/disasm.c: Err on invalid DeltaFormat.
-rw-r--r--ChangeLog10
-rw-r--r--pango/opentype/disasm.c28
-rw-r--r--pango/pango-context.c7
-rw-r--r--pango/pango-fontset.c7
4 files changed, 38 insertions, 14 deletions
diff --git a/ChangeLog b/ChangeLog
index cd2d10e5..f7aaf7d3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
2005-11-23 Behdad Esfahbod <behdad@gnome.org>
+ Protect against possible division by zeros (#316468, Steve Grubb)
+
+ * pango/pango-context.c (update_metrics_from_items),
+ pango/pango-fontset.c (pango_fontset_real_get_metrics): If count is
+ zero, do not alter approximate_{char,digit}_width.
+
+ * pango/opentype/disasm.c: Err on invalid DeltaFormat.
+
+2005-11-23 Behdad Esfahbod <behdad@gnome.org>
+
* pango/fonts.c (pango_font_description_get_absolute_size): Remove
excess "the" in docs. (#319175, Masao Mutoh)
diff --git a/pango/opentype/disasm.c b/pango/opentype/disasm.c
index f4c132f0..15464f4b 100644
--- a/pango/opentype/disasm.c
+++ b/pango/opentype/disasm.c
@@ -444,18 +444,26 @@ Dump_Device (TTO_Device *Device, FILE *stream, int indent, FT_Bool is_gsub)
break;
}
- n_per = 16 / bits;
- mask = (1 << bits) - 1;
- mask = mask << (16 - bits);
-
DUMP ("<DeltaValue>");
- for (i = Device->StartSize; i <= Device->EndSize ; i++)
+ if (!bits)
+ {
+
+ fprintf(stderr, "invalid DeltaFormat!!!!!\n");
+ }
+ else
{
- FT_UShort val = Device->DeltaValue[i / n_per];
- FT_Short signed_val = ((val << ((i % n_per) * bits)) & mask);
- dump (stream, indent, "%d", signed_val >> (16 - bits));
- if (i != Device->EndSize)
- DUMP (", ");
+ n_per = 16 / bits;
+ mask = (1 << bits) - 1;
+ mask = mask << (16 - bits);
+
+ for (i = Device->StartSize; i <= Device->EndSize ; i++)
+ {
+ FT_UShort val = Device->DeltaValue[i / n_per];
+ FT_Short signed_val = ((val << ((i % n_per) * bits)) & mask);
+ dump (stream, indent, "%d", signed_val >> (16 - bits));
+ if (i != Device->EndSize)
+ DUMP (", ");
+ }
}
DUMP ("</DeltaValue>\n");
}
diff --git a/pango/pango-context.c b/pango/pango-context.c
index de53ceac..42d200c1 100644
--- a/pango/pango-context.c
+++ b/pango/pango-context.c
@@ -1334,8 +1334,11 @@ update_metrics_from_items (PangoFontMetrics *metrics,
g_hash_table_destroy (fonts_seen);
- metrics->approximate_char_width /= count;
- metrics->approximate_digit_width /= count;
+ if (count)
+ {
+ metrics->approximate_char_width /= count;
+ metrics->approximate_digit_width /= count;
+ }
}
/**
diff --git a/pango/pango-fontset.c b/pango/pango-fontset.c
index 4f16fa31..a62169a2 100644
--- a/pango/pango-fontset.c
+++ b/pango/pango-fontset.c
@@ -182,8 +182,11 @@ pango_fontset_real_get_metrics (PangoFontset *fontset)
g_hash_table_destroy (fonts_seen);
- metrics->approximate_char_width /= count;
- metrics->approximate_digit_width /= count;
+ if (count)
+ {
+ metrics->approximate_char_width /= count;
+ metrics->approximate_digit_width /= count;
+ }
return metrics;
}