Fix for crash with malformed switch statement. Fixes #1376

This commit is contained in:
ridiculousfish 2014-03-28 16:56:44 -07:00
parent 005edf71a8
commit 74b28f0a86

View file

@ -547,13 +547,15 @@ parse_execution_result_t parse_execution_context_t::run_switch_statement(const p
_(L"switch: Expected exactly one argument, got %lu\n"),
switch_values_expanded.size());
}
if (result == parse_execution_success)
{
const wcstring &switch_value_expanded = switch_values_expanded.at(0).completion;
switch_block_t *sb = new switch_block_t();
parser->push_block(sb);
if (result == parse_execution_success)
{
/* Expand case statements */
const parse_node_t *case_item_list = get_child(statement, 3, symbol_case_item_list);
@ -597,7 +599,6 @@ parse_execution_result_t parse_execution_context_t::run_switch_statement(const p
}
}
}
}
if (result == parse_execution_success && matching_case_item != NULL)
{
@ -607,6 +608,7 @@ parse_execution_result_t parse_execution_context_t::run_switch_statement(const p
}
parser->pop_block(sb);
}
return result;
}