diff src/if_py_both.h @ 23992:faca24acb37f v8.2.2538

patch 8.2.2538: crash when using Python list iterator Commit: https://github.com/vim/vim/commit/21578271bb717f7ab7b8728e9efa54c3b60ee7e4 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Feb 21 19:12:47 2021 +0100 patch 8.2.2538: crash when using Python list iterator Problem: Crash when using Python list iterator. Solution: Increment the list reference count. (closes https://github.com/vim/vim/issues/7886)
author Bram Moolenaar <Bram@vim.org>
date Sun, 21 Feb 2021 19:15:03 +0100
parents f9526a3c9bbf
children a4fda40e0bb9
line wrap: on
line diff
--- a/src/if_py_both.h
+++ b/src/if_py_both.h
@@ -2815,6 +2815,7 @@ typedef struct
 ListIterDestruct(listiterinfo_T *lii)
 {
     list_rem_watch(lii->list, &lii->lw);
+    list_unref(lii->list);
     PyMem_Free(lii);
 }
 
@@ -2850,6 +2851,7 @@ ListIter(ListObject *self)
     list_add_watch(l, &lii->lw);
     lii->lw.lw_item = l->lv_first;
     lii->list = l;
+    ++l->lv_refcount;
 
     return IterNew(lii,
 	    (destructorfun) ListIterDestruct, (nextfun) ListIterNext,