From 858ac9d8e5d971db3d6f770d386fc964187a78b4 Mon Sep 17 00:00:00 2001 From: ZyX Date: Thu, 23 Feb 2017 01:34:25 +0300 Subject: api: Make sure dict_set_var doesn’t edit read-only values MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #6147 --- src/nvim/api/private/helpers.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/nvim/api/private/helpers.c') 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) { -- cgit