summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBehdad Esfahbod <behdad@gnome.org>2005-11-23 15:21:00 +0000
committerBehdad Esfahbod <behdad@src.gnome.org>2005-11-23 15:21:00 +0000
commitbdb64d0399a33132a94fea861ac7b5bacf906ce0 (patch)
tree1d1d7900dc134fa4b0e6011900043a92c00565c6
parent4ec0dd1fea9bdaee221ce19543849b20f58ea2d3 (diff)
downloadpango-bdb64d0399a33132a94fea861ac7b5bacf906ce0.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 05afa81b..1e44c6dc 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 a49aa3f8..544baa27 100644
--- a/pango/opentype/disasm.c
+++ b/pango/opentype/disasm.c
@@ -447,18 +447,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 cc2dee6a..58fd3eaf 100644
--- a/pango/pango-context.c
+++ b/pango/pango-context.c
@@ -1338,8 +1338,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 261b6d70..d0feb62c 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;
}