Mercurial > vim
comparison src/ops.c @ 27245:776db9e02b61 v8.2.4151
patch 8.2.4151: reading beyond the end of a line
Commit: https://github.com/vim/vim/commit/57df9e8a9f9ae1aafdde9b86b10ad907627a87dc
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Jan 20 12:10:48 2022 +0000
patch 8.2.4151: reading beyond the end of a line
Problem: Reading beyond the end of a line.
Solution: For block insert only use the offset for correcting the length.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 20 Jan 2022 13:15:04 +0100 |
parents | be5e01f3ee3b |
children | 93d4ee1e6113 |
comparison
equal
deleted
inserted
replaced
27244:e6b71732abc9 | 27245:776db9e02b61 |
---|---|
527 offset = bdp->textcol + bdp->textlen; | 527 offset = bdp->textcol + bdp->textlen; |
528 } | 528 } |
529 } | 529 } |
530 | 530 |
531 if (has_mbyte && spaces > 0) | 531 if (has_mbyte && spaces > 0) |
532 { | 532 // avoid copying part of a multi-byte character |
533 int off; | 533 offset -= (*mb_head_off)(oldp, oldp + offset); |
534 | 534 |
535 // Avoid starting halfway a multi-byte character. | |
536 if (b_insert) | |
537 { | |
538 off = (*mb_head_off)(oldp, oldp + offset + spaces); | |
539 spaces -= off; | |
540 count -= off; | |
541 } | |
542 else | |
543 { | |
544 // spaces fill the gap, the character that's at the edge moves | |
545 // right | |
546 off = (*mb_head_off)(oldp, oldp + offset); | |
547 offset -= off; | |
548 } | |
549 } | |
550 if (spaces < 0) // can happen when the cursor was moved | 535 if (spaces < 0) // can happen when the cursor was moved |
551 spaces = 0; | 536 spaces = 0; |
552 | 537 |
553 // Make sure the allocated size matches what is actually copied below. | 538 // Make sure the allocated size matches what is actually copied below. |
554 newp = alloc(STRLEN(oldp) + spaces + s_len | 539 newp = alloc(STRLEN(oldp) + spaces + s_len |