[pango/pango-1-44] renderer: Fix a division-by-zero
- From: Marco Trevisan <marcotrevi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pango/pango-1-44] renderer: Fix a division-by-zero
- Date: Wed, 5 May 2021 16:00:30 +0000 (UTC)
commit 1f75fc9089274a1fcb9ab7eb647e144f48c81fab
Author: Matthias Clasen <mclasen redhat com>
Date: Mon Jun 8 12:06:40 2020 -0400
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
(cherry-picked from commit dd867f41)
pango/pango-renderer.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
---
diff --git a/pango/pango-renderer.c b/pango/pango-renderer.c
index 889989dd..5e98fd16 100644
--- a/pango/pango-renderer.c
+++ b/pango/pango-renderer.c
@@ -974,15 +974,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)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]