From: Paul Eggert Date: Wed, 16 Jul 2025 18:38:20 +0000 (-0700) Subject: insert-file-contents small gap bug X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=120f850dfec233b5f8f22212325520d500c5dcc3;p=emacs.git insert-file-contents small gap bug Problem reported by Zhengyi Fu (Bug#79031). * src/fileio.c (Finsert_file_contents): Do not read more than requested, even when the gap is so small that we use a local buffer. (cherry picked from commit e450a7802c544b7fa14fe064c62de1f9b7098e81) --- diff --git a/src/fileio.c b/src/fileio.c index 2c8855dba91..e33ac4afabf 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -4899,8 +4899,9 @@ by calling `format-decode', which see. */) else { buf = (char *) BEG_ADDR + PT_BYTE - BEG_BYTE + inserted; - bufsize = min (min (gap_size, total - inserted), IO_BUFSIZE); + bufsize = min (gap_size, IO_BUFSIZE); } + bufsize = min (bufsize, total - inserted); if (!seekable && end_offset == TYPE_MAXIMUM (off_t)) {