Assert value of tok_begin after call to parse_util_token_extent

We later assign the value of `tok_begin` to a `wcstring` which would
cause a null dereference if `tok_begin` were still null.
This commit is contained in:
Mahmoud Al-Qudsi 2018-02-08 17:10:51 -06:00
parent fbc6c68f3d
commit 6108b1d813

View file

@ -1264,8 +1264,9 @@ void complete(const wcstring &cmd_with_subcmds, std::vector<completion_t> *out_c
// debug( 1, L"Complete '%ls'", cmd.c_str() );
const wchar_t *cmd_cstr = cmd.c_str();
const wchar_t *tok_begin = NULL, *prev_begin = NULL, *prev_end = NULL;
const wchar_t *tok_begin = nullptr, *prev_begin = nullptr, *prev_end = nullptr;
parse_util_token_extent(cmd_cstr, cmd.size(), &tok_begin, NULL, &prev_begin, &prev_end);
assert(tok_begin != nullptr);
// If we are completing a variable name or a tilde expansion user name, we do that and return.
// No need for any other completions.