aboutsummaryrefslogtreecommitdiffhomepage
path: root/parse_execution.cpp
diff options
context:
space:
mode:
authorGravatar ridiculousfish <corydoras@ridiculousfish.com>2014-03-28 16:56:44 -0700
committerGravatar ridiculousfish <corydoras@ridiculousfish.com>2014-03-28 16:56:44 -0700
commit74b28f0a8632b91f99d73f0f613d04a9d26d22e1 (patch)
tree1bfe773f61c7bb1ca1e4b21dbcf35888d0474d9d /parse_execution.cpp
parent005edf71a8ed3493b9fbbc1de81d10ed73cdca79 (diff)
Fix for crash with malformed switch statement. Fixes #1376
Diffstat (limited to 'parse_execution.cpp')
-rw-r--r--parse_execution.cpp28
1 files changed, 15 insertions, 13 deletions
diff --git a/parse_execution.cpp b/parse_execution.cpp
index 8a2e9d27..46df733c 100644
--- a/parse_execution.cpp
+++ b/parse_execution.cpp
@@ -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());
}
- 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)
{
+ const wcstring &switch_value_expanded = switch_values_expanded.at(0).completion;
+
+ switch_block_t *sb = new switch_block_t();
+ parser->push_block(sb);
+
+
/* Expand case statements */
const parse_node_t *case_item_list = get_child(statement, 3, symbol_case_item_list);
@@ -597,16 +599,16 @@ parse_execution_result_t parse_execution_context_t::run_switch_statement(const p
}
}
}
- }
- if (result == parse_execution_success && matching_case_item != NULL)
- {
- /* Success, evaluate the job list */
- const parse_node_t *job_list = get_child(*matching_case_item, 3, symbol_job_list);
- result = this->run_job_list(*job_list, sb);
- }
+ if (result == parse_execution_success && matching_case_item != NULL)
+ {
+ /* Success, evaluate the job list */
+ const parse_node_t *job_list = get_child(*matching_case_item, 3, symbol_job_list);
+ result = this->run_job_list(*job_list, sb);
+ }
- parser->pop_block(sb);
+ parser->pop_block(sb);
+ }
return result;
}