Skip to content

Commit 42f45b8

Browse files
committed
patch 8.0.0458: potential crash if adding list or dict to dict fails
Problem: Potential crash if adding list or dict to dict fails. Solution: Make sure the reference count is correct. (Nikolai Pavlov, closes #1555)
1 parent 88d298a commit 42f45b8

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/dict.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -356,12 +356,12 @@ dict_add_list(dict_T *d, char *key, list_T *list)
356356
item->di_tv.v_lock = 0;
357357
item->di_tv.v_type = VAR_LIST;
358358
item->di_tv.vval.v_list = list;
359+
++list->lv_refcount;
359360
if (dict_add(d, item) == FAIL)
360361
{
361362
dictitem_free(item);
362363
return FAIL;
363364
}
364-
++list->lv_refcount;
365365
return OK;
366366
}
367367

@@ -380,12 +380,12 @@ dict_add_dict(dict_T *d, char *key, dict_T *dict)
380380
item->di_tv.v_lock = 0;
381381
item->di_tv.v_type = VAR_DICT;
382382
item->di_tv.vval.v_dict = dict;
383+
++dict->dv_refcount;
383384
if (dict_add(d, item) == FAIL)
384385
{
385386
dictitem_free(item);
386387
return FAIL;
387388
}
388-
++dict->dv_refcount;
389389
return OK;
390390
}
391391

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -764,6 +764,8 @@ static char *(features[]) =
764764

765765
static int included_patches[] =
766766
{ /* Add new patch number below this line */
767+
/**/
768+
458,
767769
/**/
768770
457,
769771
/**/

0 commit comments

Comments
 (0)