aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/os/env.c
diff options
context:
space:
mode:
authorPrajjwal Bhandari <pbhandari@pbhandari.ca>2015-03-31 11:27:29 -0500
committerEliseo Martínez <eliseomarmol@gmail.com>2015-03-31 22:36:38 +0200
commitd2c3592da13a56cb3b4e417b8bfe2aabf013125f (patch)
tree1ce5b41e8aff6a696ee80526e8ef68c4835aa641 /src/nvim/os/env.c
parent7080041465af6ca530389e2270025f43c4932a0f (diff)
downloadrneovim-d2c3592da13a56cb3b4e417b8bfe2aabf013125f.tar.gz
rneovim-d2c3592da13a56cb3b4e417b8bfe2aabf013125f.tar.bz2
rneovim-d2c3592da13a56cb3b4e417b8bfe2aabf013125f.zip
Remove potential NULL dereference. #2316
This also removes the `#elseif defined(MSWIN)` clause. Due to the enclosing `if` block, we will never get to this point when src starts with a '%', making the whole #elseif block dead code.
Diffstat (limited to 'src/nvim/os/env.c')
-rw-r--r--src/nvim/os/env.c17
1 files changed, 7 insertions, 10 deletions
diff --git a/src/nvim/os/env.c b/src/nvim/os/env.c
index 3bea2908d5..30e44341a9 100644
--- a/src/nvim/os/env.c
+++ b/src/nvim/os/env.c
@@ -243,19 +243,16 @@ void expand_env_esc(char_u *srcp, char_u *dst, int dstlen, bool esc, bool one,
// Verify that we have found the end of a UNIX ${VAR} style variable
if (src[1] == '{' && *tail != '}') {
var = NULL;
- } else if (src[1] == '{') {
- ++tail;
- }
-#elif defined(MSWIN)
- // Verify that we have found the end of a Windows %VAR% style variable
- if (src[0] == '%' && *tail != '%') {
- var = NULL;
- } else if (src[0] == '%') {
- ++tail;
- }
+ } else {
+ if (src[1] == '{') {
+ ++tail;
+ }
#endif
*var = NUL;
var = vim_getenv(dst, &mustfree);
+#if defined(UNIX)
+ }
+#endif
} else if ( src[1] == NUL /* home directory */
|| vim_ispathsep(src[1])
|| vim_strchr((char_u *)" ,\t\n", src[1]) != NULL) {