summaryrefslogtreecommitdiff
path: root/pango
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2021-03-03 02:13:14 +0000
committerMatthias Clasen <mclasen@redhat.com>2021-03-03 02:13:14 +0000
commitf9e31856f6973a2f9ddb37cd153d413b85719187 (patch)
treef803a139b1eb081de84d0b1130eece9162a7c54a /pango
parent4dfe591823eec1d5f702a909ae9206f5fa5cb47d (diff)
parente14297e1f1fe534d4511d08826acdd40a00c2462 (diff)
downloadpango-f9e31856f6973a2f9ddb37cd153d413b85719187.tar.gz
Merge branch 'fix-attribute-splicing' into 'master'
Fix attribute splicing See merge request GNOME/pango!287
Diffstat (limited to 'pango')
-rw-r--r--pango/pango-attributes.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/pango/pango-attributes.c b/pango/pango-attributes.c
index 3ef76a70..8f23fe77 100644
--- a/pango/pango-attributes.c
+++ b/pango/pango-attributes.c
@@ -1769,6 +1769,7 @@ pango_attr_list_splice (PangoAttrList *list,
{
guint i, p;
guint upos, ulen;
+ guint end;
g_return_if_fail (list != NULL);
g_return_if_fail (other != NULL);
@@ -1783,6 +1784,8 @@ pango_attr_list_splice (PangoAttrList *list,
*/
#define CLAMP_ADD(a,b) (((a) + (b) < (a)) ? G_MAXUINT : (a) + (b))
+ end = CLAMP_ADD (upos, ulen);
+
if (list->attributes)
for (i = 0, p = list->attributes->len; i < p; i++)
{
@@ -1811,8 +1814,8 @@ pango_attr_list_splice (PangoAttrList *list,
for (i = 0, p = other->attributes->len; i < p; i++)
{
PangoAttribute *attr = pango_attribute_copy (g_ptr_array_index (other->attributes, i));
- attr->start_index = CLAMP_ADD (attr->start_index, upos);
- attr->end_index = CLAMP_ADD (attr->end_index, upos);
+ attr->start_index = MIN (CLAMP_ADD (attr->start_index, upos), end);
+ attr->end_index = MIN (CLAMP_ADD (attr->end_index, upos), end);
/* Same as above, the attribute could be squashed to zero-length; here
* pango_attr_list_change() will take care of deleting it.