aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert2025-07-21 14:56:43 -0700
committerPaul Eggert2025-07-21 16:23:18 -0700
commit8393e469e7f1771b4e167392eef169ab51c047b2 (patch)
treef6d2bf0c86d8c8b234e3928583e0e809eab19b3d /src
parente879533f4b9cd12a6847f4d69c866c29d5923541 (diff)
downloademacs-8393e469e7f1771b4e167392eef169ab51c047b2.tar.gz
emacs-8393e469e7f1771b4e167392eef169ab51c047b2.zip
insert-file-contents shrinking Solaris file fix
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.
Diffstat (limited to 'src')
-rw-r--r--src/fileio.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/fileio.c b/src/fileio.c
index 2c60405ef35..7312efb6244 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -4529,8 +4529,9 @@ by calling `format-decode', which see. */)
4529 { 4529 {
4530 /* Shrink the file's head if the file shrank to 4530 /* Shrink the file's head if the file shrank to
4531 be smaller than its head. */ 4531 be smaller than its head. */
4532 if (endpos - beg_offset < same_at_start - BEGV_BYTE) 4532 off_t offset_from_beg = endpos - beg_offset;
4533 same_at_start = endpos - beg_offset + BEGV_BYTE; 4533 if (offset_from_beg < same_at_start - BEGV_BYTE)
4534 same_at_start = max (0, offset_from_beg) + BEGV_BYTE;
4534 } 4535 }
4535 } 4536 }
4536 } 4537 }