changeset 11142:a54985a73ab2 v8.0.0458

patch 8.0.0458: potential crash if adding list or dict to dict fails commit https://github.com/vim/vim/commit/42f45b850df93b806ef44f3025aecedfffb9ae01 Author: Bram Moolenaar <Bram@vim.org> Date: Tue Mar 14 22:17:14 2017 +0100 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)
author Christian Brabandt <cb@256bit.org>
date Tue, 14 Mar 2017 22:30:05 +0100
parents b5ac92d0f31f
children ed0f1fee66f1
files src/dict.c src/version.c
diffstat 2 files changed, 4 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/dict.c
+++ b/src/dict.c
@@ -356,12 +356,12 @@ dict_add_list(dict_T *d, char *key, list
     item->di_tv.v_lock = 0;
     item->di_tv.v_type = VAR_LIST;
     item->di_tv.vval.v_list = list;
+    ++list->lv_refcount;
     if (dict_add(d, item) == FAIL)
     {
 	dictitem_free(item);
 	return FAIL;
     }
-    ++list->lv_refcount;
     return OK;
 }
 
@@ -380,12 +380,12 @@ dict_add_dict(dict_T *d, char *key, dict
     item->di_tv.v_lock = 0;
     item->di_tv.v_type = VAR_DICT;
     item->di_tv.vval.v_dict = dict;
+    ++dict->dv_refcount;
     if (dict_add(d, item) == FAIL)
     {
 	dictitem_free(item);
 	return FAIL;
     }
-    ++dict->dv_refcount;
     return OK;
 }
 
--- a/src/version.c
+++ b/src/version.c
@@ -765,6 +765,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    458,
+/**/
     457,
 /**/
     456,