Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit963cfa7

Browse files
authored
fix(terminal): invalid pointer comparison#18453
At the moment of comparison, the pointer save_curwin can be invalid (assuggested by the comment) because it has been free'd. Worst, the newcurwin could have been re-allocated to that same pointer, altering theexecution flow unpredictably.While there are many other potential similar cases to fix in thecodebase, the presented scenario is not hypothetical and does happen inpractice (while spawning new windows from fzf for instance).There are numerous other instances of curwin comparisons in thecodebase, and they may need further investigation.closes#16941
1 parent3a91ada commit963cfa7

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

‎src/nvim/terminal.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ void terminal_enter(void)
404404

405405
// Disable these options in terminal-mode. They are nonsense because cursor is
406406
// placed at end of buffer to "follow" output. #11072
407-
win_T*save_curwin=curwin;
407+
handle_Tsave_curwin=curwin->handle;
408408
boolsave_w_p_cul=curwin->w_p_cul;
409409
char_u*save_w_p_culopt=NULL;
410410
char_usave_w_p_culopt_flags=curwin->w_p_culopt_flags;
@@ -442,7 +442,7 @@ void terminal_enter(void)
442442
RedrawingDisabled=s->save_rd;
443443
apply_autocmds(EVENT_TERMLEAVE,NULL,NULL, false,curbuf);
444444

445-
if (save_curwin==curwin) {//save_curwin may be invalid (window closed)!
445+
if (save_curwin==curwin->handle) {//Else:windowwasclosed.
446446
curwin->w_p_cul=save_w_p_cul;
447447
if (save_w_p_culopt) {
448448
xfree(curwin->w_p_culopt);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp