Problem: getregionpos: double-free on alloc failure
Solution: Only free lists that were not appended (Yasuhiro Matsumoto).
add_regionpos_range() freed lists already linked into the result tree when
a later list_alloc()/list_append_list() failed, causing a double-free and
use-after-free. Only free lists that were not appended, and free them with
list_free() so they are unlinked from the garbage-collection chain.
related: #20668
closes: #20744
Signed-off-by: Yasuhiro Matsumoto <mattn.jp@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
if (list_append_list(rettv->vval.v_list, l1) == FAIL)
{
- vim_free(l1);
+ list_free(l1);
return;
}
l2 = list_alloc();
if (l2 == NULL)
- {
- vim_free(l1);
return;
- }
if (list_append_list(l1, l2) == FAIL)
{
- vim_free(l1);
- vim_free(l2);
+ list_free(l2);
return;
}
l3 = list_alloc();
if (l3 == NULL)
- {
- vim_free(l1);
- vim_free(l2);
return;
- }
if (list_append_list(l1, l3) == FAIL)
{
- vim_free(l1);
- vim_free(l2);
- vim_free(l3);
+ list_free(l3);
return;
}
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 808,
/**/
807,
/**/