bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#66375: 30.0.50; (error "Maximum buffer size exceeded") from (insert-


From: Eli Zaretskii
Subject: bug#66375: 30.0.50; (error "Maximum buffer size exceeded") from (insert-file-contents "/dev/null")
Date: Sat, 07 Oct 2023 10:43:24 +0300

> From: Po Lu <luangruo@yahoo.com>
> Cc: sds@gnu.org,  Paul Eggert <eggert@cs.ucla.edu>,  66375@debbugs.gnu.org
> Date: Sat, 07 Oct 2023 14:43:45 +0800
> 
> --- a/src/fileio.c
> +++ b/src/fileio.c
> @@ -4746,7 +4746,7 @@ DEFUN ("insert-file-contents", Finsert_file_contents, 
> Sinsert_file_contents,
>        goto handled;
>      }
>  
> -  if (seekable || !NILP (end))
> +  if (((regular || !NILP (end)) && seekable) || !NILP (end))
>      total = end_offset - beg_offset;
>    else
>      /* For a special file, all we can do is guess.  */
> 

This does a couple of redundant tests:

  . regular non-zero means seekable must be non-zero
  . NILP (end) is tested twice for now good reason

I think the above should be cleaned up to better understand the logic.

More generally, I think 'total' should not be computed in this naïve
way when end_offset is -1, i.e. unless end_offset is either the result
of fstat/stat or the result of actually seeking to the end of
file/device.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]