mirror of
https://github.com/neovim/neovim.git
synced 2025-09-25 04:28:33 +00:00
eval/encode: Make sure that encoder can encode NULL variables
Adds two undocumented v: variables: _null_list and _null_dict because I do not know a reproducible way to get such lists (though I think I heard about this) and dictionaries (do not remember hearing about them). NULL strings are obtained using $XXX_UNEXISTENT_VAR_XXX. Fixes crash in json_encode($XXX_UNEXISTENT_VAR_XXX). Other added tests worked fine before this commit.
This commit is contained in:
@@ -287,6 +287,9 @@ int encode_read_from_list(ListReaderState *const state, char *const buf,
|
||||
(val)->copyID_attr = copyID; \
|
||||
} while (0)
|
||||
|
||||
#define TV_STRLEN(tv) \
|
||||
(tv->vval.v_string == NULL ? 0 : STRLEN(tv->vval.v_string))
|
||||
|
||||
/// Define functions which convert VimL value to something else
|
||||
///
|
||||
/// Creates function `vim_to_{name}(firstargtype firstargname, typval_T *const
|
||||
@@ -306,7 +309,7 @@ static int name##_convert_one_value(firstargtype firstargname, \
|
||||
{ \
|
||||
switch (tv->v_type) { \
|
||||
case VAR_STRING: { \
|
||||
CONV_STRING(tv->vval.v_string, STRLEN(tv->vval.v_string)); \
|
||||
CONV_STRING(tv->vval.v_string, TV_STRLEN(tv)); \
|
||||
break; \
|
||||
} \
|
||||
case VAR_NUMBER: { \
|
||||
|
Reference in New Issue
Block a user