summaryrefslogtreecommitdiff
path: root/pango/pango-renderer.c
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2020-06-08 12:06:40 -0400
committerMatthias Clasen <mclasen@redhat.com>2020-06-08 12:06:40 -0400
commitdd867f41cc653411e716212867537e72107429a9 (patch)
treeafaff60a331361ba32f5dca753bdc2e9a0a3bfa3 /pango/pango-renderer.c
parent7310356ab0ce0c4e9c983fd43b8e423e411dc483 (diff)
downloadpango-dd867f41cc653411e716212867537e72107429a9.tar.gz
renderer: Fix a division-by-zero
We need to check if height is zero before dividing by it. For completeness, check width at the same time. This was pointed out in https://gitlab.gnome.org/GNOME/pango/-/merge_requests/167
Diffstat (limited to 'pango/pango-renderer.c')
-rw-r--r--pango/pango-renderer.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/pango/pango-renderer.c b/pango/pango-renderer.c
index 539df34a..07f81a88 100644
--- a/pango/pango-renderer.c
+++ b/pango/pango-renderer.c
@@ -1096,15 +1096,22 @@ pango_renderer_default_draw_error_underline (PangoRenderer *renderer,
int width,
int height)
{
- int square = height / HEIGHT_SQUARES;
- int unit_width = (HEIGHT_SQUARES - 1) * square;
- int width_units = (width + unit_width / 2) / unit_width;
+ int square;
+ int unit_width;
+ int width_units;
const PangoMatrix identity = PANGO_MATRIX_INIT;
const PangoMatrix *matrix;
double dx, dx0, dy0;
PangoMatrix total;
int i;
+ if (width <= 0 || height <= 0)
+ return;
+
+ square = height / HEIGHT_SQUARES;
+ unit_width = (HEIGHT_SQUARES - 1) * square;
+ width_units = (width + unit_width / 2) / unit_width;
+
x += (width - width_units * unit_width) / 2;
if (renderer->matrix)