mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-26 04:43:10 +00:00
Fix for builtin_test crash
https://github.com/fish-shell/fish-shell/issues/497
This commit is contained in:
parent
8a357e1866
commit
bf3e4126b2
3 changed files with 11 additions and 10 deletions
|
@ -772,7 +772,6 @@ static int builtin_set(parser_t &parser, wchar_t **argv)
|
|||
else
|
||||
{
|
||||
wcstring_list_t value;
|
||||
// al_init(&value);
|
||||
|
||||
while (woptind < argc)
|
||||
{
|
||||
|
@ -790,17 +789,9 @@ static int builtin_set(parser_t &parser, wchar_t **argv)
|
|||
|
||||
my_env_set(dest, result, scope);
|
||||
|
||||
// al_destroy( &value );
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// al_foreach( &result, &free );
|
||||
// al_destroy( &result );
|
||||
|
||||
// al_destroy(&indexes);
|
||||
// al_destroy(&values);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -334,11 +334,12 @@ expression *test_parser::parse_combining_expression(unsigned int start, unsigned
|
|||
std::vector<expression *> subjects;
|
||||
std::vector<token_t> combiners;
|
||||
unsigned int idx = start;
|
||||
bool first = true;
|
||||
|
||||
while (idx < end)
|
||||
{
|
||||
|
||||
if (! subjects.empty())
|
||||
if (! first)
|
||||
{
|
||||
/* This is not the first expression, so we expect a combiner. */
|
||||
token_t combiner = token_for_string(arg(idx))->tok;
|
||||
|
@ -357,12 +358,18 @@ expression *test_parser::parse_combining_expression(unsigned int start, unsigned
|
|||
if (! expr)
|
||||
{
|
||||
add_error(L"Missing argument at index %u", idx);
|
||||
if (! first)
|
||||
{
|
||||
/* Clean up the dangling combiner, since it never got its right hand expression */
|
||||
combiners.pop_back();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
/* Go to the end of this expression */
|
||||
idx = expr->range.end;
|
||||
subjects.push_back(expr);
|
||||
first = false;
|
||||
}
|
||||
|
||||
if (! subjects.empty())
|
||||
|
|
|
@ -922,6 +922,9 @@ static void test_test()
|
|||
/* These should be errors */
|
||||
assert(run_test_test(1, L"foo bar"));
|
||||
assert(run_test_test(1, L"foo bar baz"));
|
||||
|
||||
/* This crashed */
|
||||
assert(run_test_test(1, L"1 = 1 -a = 1"));
|
||||
}
|
||||
|
||||
/** Testing colors */
|
||||
|
|
Loading…
Reference in a new issue