Mercurial > vim
comparison src/ex_docmd.c @ 27072:0878d7c64140 v8.2.4065
patch 8.2.4065: computation overflow with large cound for :yank
Commit: https://github.com/vim/vim/commit/3cf21b305104e91a28e4ce3a473672b2e88a9469
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Jan 11 19:34:16 2022 +0000
patch 8.2.4065: computation overflow with large cound for :yank
Problem: Computation overflow with large cound for :yank.
Solution: Avoid an overflow.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Tue, 11 Jan 2022 20:45:02 +0100 |
parents | c9474ae175f4 |
children | c83631ad3d2a |
comparison
equal
deleted
inserted
replaced
27071:04adc77bb4b8 | 27072:0878d7c64140 |
---|---|
2372 ea.addr_count = 1; | 2372 ea.addr_count = 1; |
2373 } | 2373 } |
2374 else | 2374 else |
2375 { | 2375 { |
2376 ea.line1 = ea.line2; | 2376 ea.line1 = ea.line2; |
2377 ea.line2 += n - 1; | 2377 if (ea.line2 >= LONG_MAX - (n - 1)) |
2378 ea.line2 = LONG_MAX; // avoid overflow | |
2379 else | |
2380 ea.line2 += n - 1; | |
2378 ++ea.addr_count; | 2381 ++ea.addr_count; |
2379 /* | 2382 /* |
2380 * Be vi compatible: no error message for out of range. | 2383 * Be vi compatible: no error message for out of range. |
2381 */ | 2384 */ |
2382 if (ea.line2 > curbuf->b_ml.ml_line_count) | 2385 if (ea.line2 > curbuf->b_ml.ml_line_count) |