From: Bram Moolenaar Date: Sun, 13 Nov 2016 13:31:40 +0000 (+0100) Subject: patch 8.0.0083 X-Git-Tag: v8.0.0083 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8e639052638a9bb8c7dd6e3e10776b1218cec1a3;p=vim patch 8.0.0083 Problem: Using freed memory with win_getid(). (Domenique Pelle) Solution: For the current tab use curwin. --- diff --git a/src/testdir/test_window_id.vim b/src/testdir/test_window_id.vim index 66656e1d0..b3b506d04 100644 --- a/src/testdir/test_window_id.vim +++ b/src/testdir/test_window_id.vim @@ -92,3 +92,12 @@ func Test_win_getid() only! endfunc + +func Test_win_getid_curtab() + tabedit X + tabfirst + copen + only + call assert_equal(win_getid(1), win_getid(1, 1)) + tabclose! +endfunc diff --git a/src/version.c b/src/version.c index e85192247..c7f00a876 100644 --- a/src/version.c +++ b/src/version.c @@ -764,6 +764,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 83, /**/ 82, /**/ diff --git a/src/window.c b/src/window.c index 8e5336883..ee5f7aa8a 100644 --- a/src/window.c +++ b/src/window.c @@ -7133,7 +7133,10 @@ win_getid(typval_T *argvars) break; if (tp == NULL) return -1; - wp = tp->tp_firstwin; + if (tp == curtab) + wp = firstwin; + else + wp = tp->tp_firstwin; } for ( ; wp != NULL; wp = wp->w_next) if (--winnr == 0)