Mercurial > vim
comparison src/register.c @ 27382:123b0747fa10 v8.2.4219
patch 8.2.4219: reading before the start of the line
Commit: https://github.com/vim/vim/commit/44db8213d38c39877d2148eff6a72f4beccfb94e
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Jan 25 21:26:17 2022 +0000
patch 8.2.4219: reading before the start of the line
Problem: Reading before the start of the line.
Solution: Check boundary before trying to read the character.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Tue, 25 Jan 2022 22:30:03 +0100 |
parents | c9474ae175f4 |
children | 41e0dcf38521 |
comparison
equal
deleted
inserted
replaced
27381:c4d24fdb7fe5 | 27382:123b0747fa10 |
---|---|
1472 pnew += bd->endspaces; | 1472 pnew += bd->endspaces; |
1473 if (exclude_trailing_space) | 1473 if (exclude_trailing_space) |
1474 { | 1474 { |
1475 int s = bd->textlen + bd->endspaces; | 1475 int s = bd->textlen + bd->endspaces; |
1476 | 1476 |
1477 while (VIM_ISWHITE(*(bd->textstart + s - 1)) && s > 0) | 1477 while (s > 0 && VIM_ISWHITE(*(bd->textstart + s - 1))) |
1478 { | 1478 { |
1479 s = s - (*mb_head_off)(bd->textstart, bd->textstart + s - 1) - 1; | 1479 s = s - (*mb_head_off)(bd->textstart, bd->textstart + s - 1) - 1; |
1480 pnew--; | 1480 pnew--; |
1481 } | 1481 } |
1482 } | 1482 } |