diff src/option.c @ 27855:44a552776007 v8.2.4453

patch 8.2.4453: :helpgrep may free an option that was not allocated Commit: https://github.com/vim/vim/commit/4791fcd82565adcc60b86830e0bb6cd5b6eea0a6 Author: Bram Moolenaar <Bram@vim.org> Date: Wed Feb 23 12:06:00 2022 +0000 patch 8.2.4453: :helpgrep may free an option that was not allocated Problem: :helpgrep may free an option that was not allocated. (Yegappan Lakshmanan) Solution: Check if the value was allocated.
author Bram Moolenaar <Bram@vim.org>
date Wed, 23 Feb 2022 13:15:02 +0100
parents b5ebc885c25c
children ae38d2e81fca
line wrap: on
line diff
--- a/src/option.c
+++ b/src/option.c
@@ -4479,6 +4479,14 @@ get_encoding_default(void)
     return (char_u *)NULL;
 }
 
+    int
+is_option_allocated(char *name)
+{
+    int idx = findoption((char_u *)name);
+
+    return idx >= 0 && (options[idx].flags & P_ALLOCED);
+}
+
 /*
  * Translate a string like "t_xx", "<t_xx>" or "<S-Tab>" to a key number.
  * When "has_lt" is true there is a '<' before "*arg_arg".