Mercurial > vim
comparison 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 |
comparison
equal
deleted
inserted
replaced
23991:88faa03cdc6f | 23992:faca24acb37f |
---|---|
2813 | 2813 |
2814 static void | 2814 static void |
2815 ListIterDestruct(listiterinfo_T *lii) | 2815 ListIterDestruct(listiterinfo_T *lii) |
2816 { | 2816 { |
2817 list_rem_watch(lii->list, &lii->lw); | 2817 list_rem_watch(lii->list, &lii->lw); |
2818 list_unref(lii->list); | |
2818 PyMem_Free(lii); | 2819 PyMem_Free(lii); |
2819 } | 2820 } |
2820 | 2821 |
2821 static PyObject * | 2822 static PyObject * |
2822 ListIterNext(listiterinfo_T **lii) | 2823 ListIterNext(listiterinfo_T **lii) |
2848 | 2849 |
2849 CHECK_LIST_MATERIALIZE(l); | 2850 CHECK_LIST_MATERIALIZE(l); |
2850 list_add_watch(l, &lii->lw); | 2851 list_add_watch(l, &lii->lw); |
2851 lii->lw.lw_item = l->lv_first; | 2852 lii->lw.lw_item = l->lv_first; |
2852 lii->list = l; | 2853 lii->list = l; |
2854 ++l->lv_refcount; | |
2853 | 2855 |
2854 return IterNew(lii, | 2856 return IterNew(lii, |
2855 (destructorfun) ListIterDestruct, (nextfun) ListIterNext, | 2857 (destructorfun) ListIterDestruct, (nextfun) ListIterNext, |
2856 NULL, NULL, (PyObject *)self); | 2858 NULL, NULL, (PyObject *)self); |
2857 } | 2859 } |