option: Allow zero-length options

Code that expected NUL-terminated strings allowed them and this behaviour is
actually used.
This commit is contained in:
ZyX 2014-11-15 20:51:18 +03:00
parent 9261f1597f
commit c0bab19cf5

View File

@ -4309,13 +4309,12 @@ int findoption_len(const char_u *const arg, const size_t len)
}
}
assert(len > 0);
/*
* Check for name starting with an illegal character.
*/
if (arg[0] < 'a' || arg[0] > 'z')
if (len == 0 || arg[0] < 'a' || arg[0] > 'z') {
return -1;
}
int opt_idx;
is_term_opt = (len > 2 && arg[0] == 't' && arg[1] == '_');