comparison src/list.c @ 20770:b366a0fe8296 v8.2.0937

patch 8.2.0937: asan failure in the flatten() test Commit: https://github.com/vim/vim/commit/dcf59c37d0e1517439c4c0c4a6a5ca09c90157ad Author: Bram Moolenaar <Bram@vim.org> Date: Tue Jun 9 17:30:04 2020 +0200 patch 8.2.0937: asan failure in the flatten() test Problem: Asan failure in the flatten() test. Solution: Free the flattened list.
author Bram Moolenaar <Bram@vim.org>
date Tue, 09 Jun 2020 17:45:03 +0200
parents 821925509d8c
children 65d9189d4dca
comparison
equal deleted inserted replaced
20769:4abe06b07138 20770:b366a0fe8296
737 */ 737 */
738 static int 738 static int
739 list_flatten(list_T *list, long maxdepth) 739 list_flatten(list_T *list, long maxdepth)
740 { 740 {
741 listitem_T *item; 741 listitem_T *item;
742 listitem_T *tofree;
742 int n; 743 int n;
743 744
744 if (maxdepth == 0) 745 if (maxdepth == 0)
745 return OK; 746 return OK;
746 CHECK_LIST_MATERIALIZE(list); 747 CHECK_LIST_MATERIALIZE(list);
758 listitem_T *next = item->li_next; 759 listitem_T *next = item->li_next;
759 760
760 vimlist_remove(list, item, item); 761 vimlist_remove(list, item, item);
761 if (list_extend(list, item->li_tv.vval.v_list, next) == FAIL) 762 if (list_extend(list, item->li_tv.vval.v_list, next) == FAIL)
762 return FAIL; 763 return FAIL;
764 clear_tv(&item->li_tv);
765 tofree = item;
763 766
764 if (item->li_prev == NULL) 767 if (item->li_prev == NULL)
765 item = list->lv_first; 768 item = list->lv_first;
766 else 769 else
767 item = item->li_prev->li_next; 770 item = item->li_prev->li_next;
771 list_free_item(list, tofree);
768 772
769 if (++n >= maxdepth) 773 if (++n >= maxdepth)
770 { 774 {
771 n = 0; 775 n = 0;
772 item = next; 776 item = next;