Mercurial > vim
diff src/eval.c @ 9127:1b41750311b6 v7.4.1847
commit https://github.com/vim/vim/commit/13ddc5c35921efa69e980284117b6db6465e019c
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed May 25 22:51:17 2016 +0200
patch 7.4.1847
Problem: Getting an item from a NULL dict crashes. Setting a register to a
NULL list crashes. (Nikolai Pavlov, issue https://github.com/vim/vim/issues/768) Comparing a NULL
dict with a NULL dict fails.
Solution: Properly check for NULL.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Wed, 25 May 2016 23:00:07 +0200 |
parents | 7350959e53c3 |
children | c2fe86f2bda1 |
line wrap: on
line diff
--- a/src/eval.c +++ b/src/eval.c @@ -6230,6 +6230,8 @@ dict_equal( dictitem_T *item2; int todo; + if (d1 == NULL && d2 == NULL) + return TRUE; if (d1 == NULL || d2 == NULL) return FALSE; if (d1 == d2) @@ -7763,6 +7765,8 @@ dict_find(dict_T *d, char_u *key, int le char_u *tofree = NULL; hashitem_T *hi; + if (d == NULL) + return NULL; if (len < 0) akey = key; else if (len >= AKEYLEN) @@ -18603,8 +18607,12 @@ f_setreg(typval_T *argvars, typval_T *re char_u buf[NUMBUFLEN]; char_u **curval; char_u **curallocval; - int len = argvars[1].vval.v_list->lv_len; + list_T *ll = argvars[1].vval.v_list; listitem_T *li; + int len; + + /* If the list is NULL handle like an empty list. */ + len = ll == NULL ? 0 : ll->lv_len; /* First half: use for pointers to result lines; second half: use for * pointers to allocated copies. */ @@ -18615,7 +18623,7 @@ f_setreg(typval_T *argvars, typval_T *re allocval = lstval + len + 2; curallocval = allocval; - for (li = argvars[1].vval.v_list->lv_first; li != NULL; + for (li = ll == NULL ? NULL : ll->lv_first; li != NULL; li = li->li_next) { strval = get_tv_string_buf_chk(&li->li_tv, buf);