diff options
author | erw7 <erw7.github@gmail.com> | 2019-10-21 07:47:08 +0900 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2019-10-20 15:47:08 -0700 |
commit | 6fd6f4683d19d5ca18f48c1d1f0d87113e80368e (patch) | |
tree | 3182944f5f7a77f5dcb8bd43918f7a4ada8e4b19 | |
parent | 019c8d13dd7056725c0715dc15e451118b767b7d (diff) | |
download | rneovim-6fd6f4683d19d5ca18f48c1d1f0d87113e80368e.tar.gz rneovim-6fd6f4683d19d5ca18f48c1d1f0d87113e80368e.tar.bz2 rneovim-6fd6f4683d19d5ca18f48c1d1f0d87113e80368e.zip |
TUI/thread: guard env map from potential race with unibilium #11259
unibi_from_term calls getenv internally, so exclusive control is required.
-rw-r--r-- | src/nvim/os/env.c | 10 | ||||
-rw-r--r-- | src/nvim/tui/tui.c | 2 |
2 files changed, 12 insertions, 0 deletions
diff --git a/src/nvim/os/env.c b/src/nvim/os/env.c index ae61e54993..eb86cb8ac7 100644 --- a/src/nvim/os/env.c +++ b/src/nvim/os/env.c @@ -44,6 +44,16 @@ void env_init(void) uv_mutex_init(&mutex); } +void os_env_var_lock(void) +{ + uv_mutex_lock(&mutex); +} + +void os_env_var_unlock(void) +{ + uv_mutex_unlock(&mutex); +} + /// Like getenv(), but returns NULL if the variable is empty. /// @see os_env_exists const char *os_getenv(const char *name) diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index 150862bb18..945b093f32 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -234,7 +234,9 @@ static void terminfo_start(UI *ui) // Set up unibilium/terminfo. char *termname = NULL; if (term) { + os_env_var_lock(); data->ut = unibi_from_term(term); + os_env_var_unlock(); if (data->ut) { termname = xstrdup(term); } |