To: vim_dev@googlegroups.com Subject: Patch 8.0.1446 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.0.1446 Problem: Acessing freed memory after window command in auto command. (gy741) Solution: Adjust the pointer in the parent frame. (Christian Brabandt, closes #2467) Files: src/window.c, src/testdir/test_window_cmd.vim *** ../vim-8.0.1445/src/window.c 2017-12-25 14:29:11.487240231 +0100 --- src/window.c 2018-01-31 18:56:23.170706874 +0100 *************** *** 2731,2736 **** --- 2731,2738 ---- if (frp2->fr_win != NULL) frp2->fr_win->w_frame = frp2->fr_parent; frp = frp2->fr_parent; + if (topframe->fr_child == frp2) + topframe->fr_child = frp; vim_free(frp2); frp2 = frp->fr_parent; *************** *** 2754,2759 **** --- 2756,2763 ---- break; } } + if (topframe->fr_child == frp) + topframe->fr_child = frp2; vim_free(frp); } } *************** *** 3499,3505 **** topframe = curwin->w_frame; topframe->fr_width = Columns; topframe->fr_height = Rows - p_ch; - topframe->fr_win = curwin; return OK; } --- 3503,3508 ---- *************** *** 4812,4818 **** --- 4815,4826 ---- if (frp->fr_prev != NULL) frp->fr_prev->fr_next = frp->fr_next; else + { frp->fr_parent->fr_child = frp->fr_next; + /* special case: topframe->fr_child == frp */ + if (topframe->fr_child == frp) + topframe->fr_child = frp->fr_next; + } if (frp->fr_next != NULL) frp->fr_next->fr_prev = frp->fr_prev; } *** ../vim-8.0.1445/src/testdir/test_window_cmd.vim 2017-12-19 12:27:19.378404474 +0100 --- src/testdir/test_window_cmd.vim 2018-01-31 18:48:55.261727538 +0100 *************** *** 472,475 **** --- 472,486 ---- exe "norm! v\:\echo v:version" endfunc + func Test_access_freed_mem() + " This was accessing freed memory + au * 0 vs xxx + arg 0 + argadd + all + all + au! + bwipe xxx + endfunc + " vim: shiftwidth=2 sts=2 expandtab *** ../vim-8.0.1445/src/version.c 2018-01-31 15:48:01.105171594 +0100 --- src/version.c 2018-01-31 18:32:38.879981464 +0100 *************** *** 773,774 **** --- 773,776 ---- { /* Add new patch number below this line */ + /**/ + 1446, /**/ -- The software said it requires Windows 95 or better, so I installed Linux. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///