[pango/fix-attr-list-update: 1/2] Avoid unsigned int pitfalls
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pango/fix-attr-list-update: 1/2] Avoid unsigned int pitfalls
- Date: Sun, 23 May 2021 16:41:53 +0000 (UTC)
commit 0e9dcc976b2a3f08f239d393f49ca2907cec099b
Author: Matthias Clasen <mclasen redhat com>
Date: Sun May 23 12:39:57 2021 -0400
Avoid unsigned int pitfalls
When we tried to catch attr list overflow in
895759096309e7c, we overlooked that add - remove
can be negative, leading to unexpected results.
Avoid this case.
Fixes: #561
pango/pango-attributes.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
---
diff --git a/pango/pango-attributes.c b/pango/pango-attributes.c
index 63c031f9..f97892a6 100644
--- a/pango/pango-attributes.c
+++ b/pango/pango-attributes.c
@@ -1777,7 +1777,8 @@ pango_attr_list_update (PangoAttrList *list,
}
else if (attr->end_index >= pos + remove)
{
- if (G_MAXUINT - attr->end_index < add - remove)
+ if (add > remove &&
+ G_MAXUINT - attr->end_index < add - remove)
attr->end_index = G_MAXUINT;
else
attr->end_index += add - remove;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]