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.
This commit is contained in:
Prajjwal Bhandari 2015-03-31 11:27:29 -05:00 committed by Eliseo Martínez
parent 7080041465
commit d2c3592da1

View File

@ -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] == '%') {
} 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) {