New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Resizing window crashes while editing file containing NUL and using showbreak and breakindentopt=shift:4 #8817
Comments
yes, diff --git a/src/drawline.c b/src/drawline.c
index deeaf5f16..fe56904db 100644
--- a/src/drawline.c
+++ b/src/drawline.c
@@ -1979,9 +1979,12 @@ win_line(
// We have just drawn the showbreak value, no need to add
// space for it again
- if (vcol == vcol_sbr)
+ if (vcol == vcol_sbr && n_extra > 0)
n_extra -= MB_CHARLEN(get_showbreak_value(wp));
+ if (n_extra < 0)
+ n_extra = 0;
+
if (c == TAB && n_extra + col > wp->w_width)
# ifdef FEAT_VARTABS
n_extra = tabstop_padding(vcol, wp->w_buffer->b_p_ts, |
Unfortunately, I'm not building my own vim so I can't check your patch. I'm using the pdbs provided by vim-win32-installer to debug. |
That fix looks like it might solve the problem. I cannot reproduce the crash though. Can the example be turned into a test? |
I tried to reproduce but I could not on Linux x86_64. |
I included the fix, since we don't want Vim to crash. Still, it would be good to have a test (which would fail without the fix). |
I can confirm that the fix works. Updated to 8.2.3399 and can no longer reproduce. Thanks! |
I tried writing a test, but couldn't figure out how to do the NUL insertion:
|
Yegappan made a test for this, it was included with 8.2.3397 |
…ptions Problem: Crash with combination of 'linebreak' and other options. Solution: Avoid n_extra to become negative. (Christian Brabandt, closes vim/vim#8817) vim/vim@20e0c3d
…ptions Problem: Crash with combination of 'linebreak' and other options. Solution: Avoid n_extra to become negative. (Christian Brabandt, closes vim/vim#8817) vim/vim@20e0c3d
…ptions Problem: Crash with combination of 'linebreak' and other options. Solution: Avoid n_extra to become negative. (Christian Brabandt, closes vim/vim#8817) vim/vim@20e0c3d
…ptions Problem: Crash with combination of 'linebreak' and other options. Solution: Avoid n_extra to become negative. (Christian Brabandt, closes vim/vim#8817) vim/vim@20e0c3d
Describe the bug
Vim crashes when resizing while editing a file containing a long line with null bytes and while using specific 'linebreak' settings.
I encountered this bug while vertically splitting my window while editing Steam's vdf files. I've narrowed it down to a minimal repro using application window resizing.
To Reproduce
minimal.vim:
c:/scratch/broken.txt:
(see minimal for replacing 0 with NUL.)
Detailed steps to reproduce the behavior:
gvim --clean -Nu minimal.vim
Actual behavior
Crash
Expected behavior
Window shrinks
Debugging
I attached a debugger and it's crashing on this line (might be the wrong version of the file)):
vim/src/drawline.c
Line 2294 in 6e82351
with this callstack:
Watch variables
Seems wrong that n_extra is negative, but I'm not sure that's causing the crash.
Environment :
VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Aug 22 2021 22:02:37)
MS-Windows 64-bit GUI version with OLE support
Included patches: 1-3367
(from vim/vim-win32-installer, installed via scoop)
Win10 x64
GUI
The text was updated successfully, but these errors were encountered: