diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2019-07-23 19:20:07 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-07-23 19:20:07 +0200 |
commit | 5cccfa7c5a3cd1683c8a36da02b424d4469b2143 (patch) | |
tree | e0aef31c417c6df9a44129cd0d01e86c30882dbb /src/nvim/os/env.c | |
parent | 0d5f629208bc916bdefaea690177846e9269b4fa (diff) | |
parent | 465a0a3c09ece20c16c08e694ec9f47aeafb47fc (diff) | |
download | rneovim-5cccfa7c5a3cd1683c8a36da02b424d4469b2143.tar.gz rneovim-5cccfa7c5a3cd1683c8a36da02b424d4469b2143.tar.bz2 rneovim-5cccfa7c5a3cd1683c8a36da02b424d4469b2143.zip |
Merge #10558 from erw7/fix-text-overrides-line-number2
Windows: Fix text overrides line number
Diffstat (limited to 'src/nvim/os/env.c')
-rw-r--r-- | src/nvim/os/env.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/nvim/os/env.c b/src/nvim/os/env.c index b067de608b..2278c325ea 100644 --- a/src/nvim/os/env.c +++ b/src/nvim/os/env.c @@ -105,6 +105,10 @@ bool os_env_exists(const char *name) return (r == 0 || r == UV_ENOBUFS); } +/// Sets an environment variable. +/// +/// @warning Existing pointers to the result of os_getenv("foo") are +/// INVALID after os_setenv("foo", …). int os_setenv(const char *name, const char *value, int overwrite) FUNC_ATTR_NONNULL_ALL { @@ -121,9 +125,11 @@ int os_setenv(const char *name, const char *value, int overwrite) } #endif uv_mutex_lock(&mutex); - pmap_del2(envmap, name); int r = uv_os_setenv(name, value); assert(r != UV_EINVAL); + // Destroy the old map item. Do this AFTER uv_os_setenv(), because `value` + // could be a previous os_getenv() result. + pmap_del2(envmap, name); if (r != 0) { ELOG("uv_os_setenv(%s) failed: %d %s", name, r, uv_err_name(r)); } |