summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2021-05-23 12:39:57 -0400
committerMatthias Clasen <mclasen@redhat.com>2021-05-23 12:41:46 -0400
commit0e9dcc976b2a3f08f239d393f49ca2907cec099b (patch)
tree3e968cbfe442b7399e1bd9b1c81b5edcf50940d9
parent483b7cc92a4d81dbd395f0b9ddbab4678d33884e (diff)
downloadpango-0e9dcc976b2a3f08f239d393f49ca2907cec099b.tar.gz
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
-rw-r--r--pango/pango-attributes.c3
1 files changed, 2 insertions, 1 deletions
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;