Mercurial > vim
comparison src/list.c @ 25194:6c75baaa54ee v8.2.3133
patch 8.2.3133: Vim9: memory leak when add() fails
Commit: https://github.com/vim/vim/commit/90fba5627b361dbc970b3afc2eebf7411c49a0cc
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri Jul 9 19:17:55 2021 +0200
patch 8.2.3133: Vim9: memory leak when add() fails
Problem: Vim9: memory leak when add() fails.
Solution: Allocate listitem_T after type check.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Fri, 09 Jul 2021 19:30:06 +0200 |
parents | 14448e7acdb2 |
children | 8b7ea875afed |
comparison
equal
deleted
inserted
replaced
25193:aa10290ecb6f | 25194:6c75baaa54ee |
---|---|
600 * Return FAIL when out of memory or the type is wrong. | 600 * Return FAIL when out of memory or the type is wrong. |
601 */ | 601 */ |
602 int | 602 int |
603 list_append_tv(list_T *l, typval_T *tv) | 603 list_append_tv(list_T *l, typval_T *tv) |
604 { | 604 { |
605 listitem_T *li = listitem_alloc(); | 605 listitem_T *li; |
606 | 606 |
607 if (l->lv_type != NULL && l->lv_type->tt_member != NULL | 607 if (l->lv_type != NULL && l->lv_type->tt_member != NULL |
608 && check_typval_arg_type(l->lv_type->tt_member, tv, 0) == FAIL) | 608 && check_typval_arg_type(l->lv_type->tt_member, tv, 0) == FAIL) |
609 return FAIL; | 609 return FAIL; |
610 li = listitem_alloc(); | |
610 if (li == NULL) | 611 if (li == NULL) |
611 return FAIL; | 612 return FAIL; |
612 copy_tv(tv, &li->li_tv); | 613 copy_tv(tv, &li->li_tv); |
613 list_append(l, li); | 614 list_append(l, li); |
614 return OK; | 615 return OK; |