From 83ced05984b35fa4a12af2a2b95b6ac58435044d Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sun, 12 Jul 2026 14:36:18 +0200 Subject: [PATCH] fix(ctx): coverity CHECKED_RETURN CID 649145: Error handling issues CHECKED_RETURN /src/nvim/api/window.c: 138 in nvim_win_set_cursor() 132 // Make sure we stick in this column. 133 w->w_set_curswant = true; 134 135 // make sure cursor is in visible range and 136 // cursorcolumn and cursorline are updated even if w != curwin 137 CtxSwitch switchwin; >>> CID 649145: Error handling issues (CHECKED_RETURN) >>> Calling "ctx_switch" without checking return value (as is done elsewhere 5 out of 6 times). 138 ctx_switch(&switchwin, w, NULL, NULL, kCtxNoEvents | kCtxNoDisplay); 139 update_topline(curwin); 140 validate_cursor(curwin); 141 ctx_restore(&switchwin); 142 143 redraw_later(w, UPD_VALID); --- src/nvim/api/window.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/nvim/api/window.c b/src/nvim/api/window.c index bb564400fc..b1ffa0f6f2 100644 --- a/src/nvim/api/window.c +++ b/src/nvim/api/window.c @@ -135,9 +135,10 @@ void nvim_win_set_cursor(Window win, ArrayOf(Integer, 2) pos, Error *err) // make sure cursor is in visible range and // cursorcolumn and cursorline are updated even if w != curwin CtxSwitch switchwin; - ctx_switch(&switchwin, w, NULL, NULL, kCtxNoEvents | kCtxNoDisplay); - update_topline(curwin); - validate_cursor(curwin); + if (ctx_switch(&switchwin, w, NULL, NULL, kCtxNoEvents | kCtxNoDisplay)) { + update_topline(curwin); + validate_cursor(curwin); + } ctx_restore(&switchwin); redraw_later(w, UPD_VALID);