diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/fileio.c | 28 |
1 files changed, 12 insertions, 16 deletions
diff --git a/src/fileio.c b/src/fileio.c index e20249379e7..2c8855dba91 100644 --- a/src/fileio.c +++ b/src/fileio.c | |||
| @@ -4255,22 +4255,18 @@ by calling `format-decode', which see. */) | |||
| 4255 | 4255 | ||
| 4256 | /* Check now whether the buffer will become too large, | 4256 | /* Check now whether the buffer will become too large, |
| 4257 | in the likely case where the file's length is not changing. | 4257 | in the likely case where the file's length is not changing. |
| 4258 | This saves a lot of needless work before a buffer overflow. */ | 4258 | This saves a lot of needless work before a buffer overflow. |
| 4259 | if (regular) | 4259 | If LIKELY_END is nonnegative, it is likely where we will stop reading. |
| 4260 | { | 4260 | We could read more (or less), if the file grows (or shrinks). */ |
| 4261 | /* The likely offset where we will stop reading. We could read | 4261 | off_t likely_end = min (end_offset, file_size_hint); |
| 4262 | more (or less), if the file grows (or shrinks) as we read it. */ | 4262 | if (beg_offset < likely_end) |
| 4263 | off_t likely_end = min (end_offset, file_size_hint); | 4263 | { |
| 4264 | 4264 | ptrdiff_t buf_bytes | |
| 4265 | if (beg_offset < likely_end) | 4265 | = Z_BYTE - (!NILP (replace) ? ZV_BYTE - BEGV_BYTE : 0); |
| 4266 | { | 4266 | ptrdiff_t buf_growth_max = BUF_BYTES_MAX - buf_bytes; |
| 4267 | ptrdiff_t buf_bytes | 4267 | off_t likely_growth = likely_end - beg_offset; |
| 4268 | = Z_BYTE - (!NILP (replace) ? ZV_BYTE - BEGV_BYTE : 0); | 4268 | if (buf_growth_max < likely_growth) |
| 4269 | ptrdiff_t buf_growth_max = BUF_BYTES_MAX - buf_bytes; | 4269 | buffer_overflow (); |
| 4270 | off_t likely_growth = likely_end - beg_offset; | ||
| 4271 | if (buf_growth_max < likely_growth) | ||
| 4272 | buffer_overflow (); | ||
| 4273 | } | ||
| 4274 | } | 4270 | } |
| 4275 | 4271 | ||
| 4276 | /* Prevent redisplay optimizations. */ | 4272 | /* Prevent redisplay optimizations. */ |