diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2016-12-15 06:40:55 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-12-15 06:40:55 +0100 |
commit | 02a9824438adb89eed8b0230068bb95bbf7ce97c (patch) | |
tree | 98e15d480351d39e90bb1c5f2102ee22d58da95b /src | |
parent | f089d299e33e9f5d1a52aa6d3b9c1ea43bb2e51c (diff) | |
parent | b29c5dd3848d3621dfbb00f8f940506cc1048fd1 (diff) | |
download | rneovim-02a9824438adb89eed8b0230068bb95bbf7ce97c.tar.gz rneovim-02a9824438adb89eed8b0230068bb95bbf7ce97c.tar.bz2 rneovim-02a9824438adb89eed8b0230068bb95bbf7ce97c.zip |
Merge #5772 from justinmk/fixsegfault
eval.c: set_selfdict(): Fix invalid memory access.
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/eval.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c index a205c37d6e..982074f62a 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -18665,15 +18665,17 @@ handle_subscript ( return ret; } -static void set_selfdict(typval_T *rettv, dict_T *selfdict) { +static void set_selfdict(typval_T *rettv, dict_T *selfdict) +{ // Don't do this when "dict.Func" is already a partial that was bound // explicitly (pt_auto is false). if (rettv->v_type == VAR_PARTIAL && !rettv->vval.v_partial->pt_auto && rettv->vval.v_partial->pt_dict != NULL) { return; } - char_u *fname = rettv->v_type == VAR_FUNC ? rettv->vval.v_string - : rettv->vval.v_partial->pt_name; + char_u *fname = rettv->v_type == VAR_FUNC || rettv->v_type == VAR_STRING + ? rettv->vval.v_string + : rettv->vval.v_partial->pt_name; char_u *tofree = NULL; ufunc_T *fp; char_u fname_buf[FLEN_FIXED + 1]; @@ -18694,7 +18696,7 @@ static void set_selfdict(typval_T *rettv, dict_T *selfdict) { pt->pt_dict = selfdict; (selfdict->dv_refcount)++; pt->pt_auto = true; - if (rettv->v_type == VAR_FUNC) { + if (rettv->v_type == VAR_FUNC || rettv->v_type == VAR_STRING) { // Just a function: Take over the function name and use selfdict. pt->pt_name = rettv->vval.v_string; } else { |