From 887cc68c36f31c5d8796c377919c186870d2b198 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sun, 23 May 2021 21:03:22 -0400 Subject: Explicitly preserve unlimited attributes When calling pango_attr_list_update(), we must not change the limits or attributes that are unlimited. --- pango/pango-attributes.c | 42 ++++++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 18 deletions(-) (limited to 'pango/pango-attributes.c') diff --git a/pango/pango-attributes.c b/pango/pango-attributes.c index 8b4b2f7a..0d604f3d 100644 --- a/pango/pango-attributes.c +++ b/pango/pango-attributes.c @@ -1760,28 +1760,34 @@ pango_attr_list_update (PangoAttrList *list, continue; } - if (attr->start_index >= pos && - attr->start_index < pos + remove) - { - attr->start_index = pos + add; - } - else if (attr->start_index >= pos + remove) + if (attr->start_index != PANGO_ATTR_INDEX_FROM_TEXT_BEGINNING) { - attr->start_index += add - remove; + if (attr->start_index >= pos && + attr->start_index < pos + remove) + { + attr->start_index = pos + add; + } + else if (attr->start_index >= pos + remove) + { + attr->start_index += add - remove; + } } - if (attr->end_index >= pos && - attr->end_index < pos + remove) - { - attr->end_index = pos; - } - else if (attr->end_index >= pos + remove) + if (attr->end_index != PANGO_ATTR_INDEX_TO_TEXT_END) { - if (add > remove && - G_MAXUINT - attr->end_index < add - remove) - attr->end_index = G_MAXUINT; - else - attr->end_index += add - remove; + if (attr->end_index >= pos && + attr->end_index < pos + remove) + { + attr->end_index = pos; + } + else if (attr->end_index >= pos + remove) + { + if (add > remove && + G_MAXUINT - attr->end_index < add - remove) + attr->end_index = G_MAXUINT; + else + attr->end_index += add - remove; + } } } } -- cgit v1.2.1