diff options
author | ZyX <kp-pav@yandex.ru> | 2017-02-23 01:34:25 +0300 |
---|---|---|
committer | ZyX <kp-pav@yandex.ru> | 2017-02-23 19:48:41 +0300 |
commit | 858ac9d8e5d971db3d6f770d386fc964187a78b4 (patch) | |
tree | 6e8fda441bdab09dd3f3343f5743fd8d5e644121 /src/nvim/api/private/helpers.c | |
parent | 8faa4af39673ac032362b62662eb049f588fef81 (diff) | |
download | rneovim-858ac9d8e5d971db3d6f770d386fc964187a78b4.tar.gz rneovim-858ac9d8e5d971db3d6f770d386fc964187a78b4.tar.bz2 rneovim-858ac9d8e5d971db3d6f770d386fc964187a78b4.zip |
api: Make sure dict_set_var doesn’t edit read-only values
Fixes #6147
Diffstat (limited to 'src/nvim/api/private/helpers.c')
-rw-r--r-- | src/nvim/api/private/helpers.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/nvim/api/private/helpers.c b/src/nvim/api/private/helpers.c index 23f5b10e18..7efa086af2 100644 --- a/src/nvim/api/private/helpers.c +++ b/src/nvim/api/private/helpers.c @@ -131,6 +131,19 @@ Object dict_set_var(dict_T *dict, String key, Object value, bool del, dictitem_T *di = dict_find(dict, (char_u *)key.data, (int)key.size); + if (di != NULL) { + if (di->di_flags & DI_FLAGS_RO) { + api_set_error(err, Exception, _("Key is read-only: %s"), key.data); + return rv; + } else if (di->di_flags & DI_FLAGS_FIX) { + api_set_error(err, Exception, _("Key is fixed: %s"), key.data); + return rv; + } else if (di->di_flags & DI_FLAGS_LOCK) { + api_set_error(err, Exception, _("Key is locked: %s"), key.data); + return rv; + } + } + if (del) { // Delete the key if (di == NULL) { |