eval: Make sure that v:_null_dict does not crash dictwatcher*()

Ref #4615
This commit is contained in:
ZyX
2016-12-04 22:59:25 +03:00
parent a56f2d27e3
commit 3025431c81
2 changed files with 27 additions and 0 deletions

View File

@@ -808,6 +808,9 @@ void tv_dict_watcher_add(dict_T *const dict, const char *const key_pattern,
const size_t key_pattern_len, Callback callback)
FUNC_ATTR_NONNULL_ARG(2)
{
if (dict == NULL) {
return;
}
DictWatcher *const watcher = xmalloc(sizeof(DictWatcher));
watcher->key_pattern = xmemdupz(key_pattern, key_pattern_len);
watcher->key_pattern_len = key_pattern_len;