]> git.eshelyaron.com Git - emacs.git/commitdiff
insert-file-contents small gap bug
authorPaul Eggert <eggert@cs.ucla.edu>
Wed, 16 Jul 2025 18:38:20 +0000 (11:38 -0700)
committerEshel Yaron <me@eshelyaron.com>
Thu, 24 Jul 2025 11:53:22 +0000 (13:53 +0200)
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)

src/fileio.c

index 2c8855dba911a7114eea8cd02dd231d6ac0e00f1..e33ac4afabf1003fbfad05cb695ae1fafa1fc050 100644 (file)
@@ -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))
          {