From f21725946c575884e04e79942850e7d0bc040ef9 Mon Sep 17 00:00:00 2001 From: ZyX Date: Tue, 3 Jan 2017 16:13:21 +0300 Subject: eval/encode: Fail when stringifying NULL functions --- src/nvim/eval/encode.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/nvim/eval/encode.c b/src/nvim/eval/encode.c index ef1e77459a..828bde3124 100644 --- a/src/nvim/eval/encode.c +++ b/src/nvim/eval/encode.c @@ -336,8 +336,14 @@ int encode_read_from_list(ListReaderState *const state, char *const buf, #define TYPVAL_ENCODE_CONV_FUNC_START(tv, fun) \ do { \ - ga_concat(gap, "function("); \ - TYPVAL_ENCODE_CONV_STRING(tv, fun, STRLEN(fun)); \ + const char *const fun_ = (const char *)(fun); \ + if (fun_ == NULL) { \ + EMSG2(_(e_intern2), "string(): NULL function name"); \ + ga_concat(gap, "function(NULL"); \ + } else { \ + ga_concat(gap, "function("); \ + TYPVAL_ENCODE_CONV_STRING(tv, fun_, strlen(fun_)); \ + }\ } while (0) #define TYPVAL_ENCODE_CONV_FUNC_BEFORE_ARGS(tv, len) \ -- cgit