- else if (XINT (end) > max)
- /* The end-point is past the end of the new string. */
- XSETCAR (XCDR (item), new_end);
+ else if ((end == XINT (old_end) && end != max)
+ || end > max)
+ {
+ /* Either the end-point is past the end of the new string,
+ and we need to discard the properties past the new end,
+ or the caller is extending the property range, and we
+ should update all end-points that are on the old end of
+ the range to reflect that. */
+ XSETCAR (XCDR (item), new_end);
+ }