This is related to recent fixes for Bug#77315.
* src/fileio.c (Finsert_file_contents): Defend against
a file shrinking to be smaller than its initial offset.
This can happen only on platforms like Solaris where
the initial offset can be positive.
(cherry picked from commit
8393e469e7f1771b4e167392eef169ab51c047b2)
{
/* Shrink the file's head if the file shrank to
be smaller than its head. */
- if (endpos - beg_offset < same_at_start - BEGV_BYTE)
- same_at_start = endpos - beg_offset + BEGV_BYTE;
+ off_t offset_from_beg = endpos - beg_offset;
+ if (offset_from_beg < same_at_start - BEGV_BYTE)
+ same_at_start = max (0, offset_from_beg) + BEGV_BYTE;
}
}
}