summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBehdad Esfahbod <behdad@behdad.org>2009-05-01 14:05:31 -0400
committerBehdad Esfahbod <behdad@behdad.org>2009-05-01 14:05:31 -0400
commit2c9979d6a01b5fb4951f1413ad8468ed10415c64 (patch)
tree2669736d0b22c9b35c1b6587f10b8bc100880413
parent150573e610c0b14c34aba6fe17b1a6e36d282767 (diff)
downloadpango-2c9979d6a01b5fb4951f1413ad8468ed10415c64.tar.gz
Bug 580987 – SIGFPE in pango_glyph_string_index_to_x
Be pedantic about broken cluster setup, avoid div-by-zero.
-rw-r--r--pango/glyphstring.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/pango/glyphstring.c b/pango/glyphstring.c
index 8fb70313..2e3a9f80 100644
--- a/pango/glyphstring.c
+++ b/pango/glyphstring.c
@@ -506,6 +506,12 @@ pango_glyph_string_index_to_x (PangoGlyphString *glyphs,
if (trailing)
cluster_offset += 1;
+ if (G_UNLIKELY (!cluster_chars)) /* pedantic */
+ {
+ *x_pos = start_xpos;
+ return;
+ }
+
*x_pos = ((cluster_chars - cluster_offset) * start_xpos +
cluster_offset * end_xpos) / cluster_chars;
}