From 0f83b9f0c34e72c01730bb5cf0250f02a5c30a6e Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Thu, 17 Jul 2008 06:12:04 -0400 Subject: Moved the sequencing of a call to node.reset, since the intervening expression can throw an exception which would leave us with an unexpected NULL pointer. --- valexpr.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'valexpr.cc') diff --git a/valexpr.cc b/valexpr.cc index d1cc9322..6afd0805 100644 --- a/valexpr.cc +++ b/valexpr.cc @@ -1035,8 +1035,8 @@ value_expr_t * parse_value_term(std::istream& in, scope_t * scope, unexpected(c, ']'); in.get(c); - node.reset(new value_expr_t(value_expr_t::CONSTANT)); interval_t timespan(buf); + node.reset(new value_expr_t(value_expr_t::CONSTANT)); node->value = new value_t(timespan.first()); break; } -- cgit v1.2.3 From 78813fc6169f70b804b917b57ded2b9f5b2fb124 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Thu, 17 Jul 2008 17:49:08 -0400 Subject: Rather than just aborting, report an intelligent error if the comma operator is missing one of its operands in a value expression. This kind of reporting still needs to be done for all the other operators as well. --- valexpr.cc | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'valexpr.cc') diff --git a/valexpr.cc b/valexpr.cc index 6afd0805..5b5d29ba 100644 --- a/valexpr.cc +++ b/valexpr.cc @@ -578,8 +578,12 @@ void value_expr_t::compute(value_t& result, const details_t& details, } case O_COM: - assert(left); - assert(right); + if (! left) + throw new compute_error("Comma operator missing left operand", + new valexpr_context(this)); + if (! right) + throw new compute_error("Comma operator missing right operand", + new valexpr_context(this)); left->compute(result, details, context); right->compute(result, details, context); break; @@ -1731,10 +1735,12 @@ bool write_value_expr(std::ostream& out, break; case value_expr_t::O_COM: - if (write_value_expr(out, node->left, relaxed, node_to_find, start_pos, end_pos)) + if (node->left && + write_value_expr(out, node->left, relaxed, node_to_find, start_pos, end_pos)) found = true; out << ", "; - if (write_value_expr(out, node->right, relaxed, node_to_find, start_pos, end_pos)) + if (node->right && + write_value_expr(out, node->right, relaxed, node_to_find, start_pos, end_pos)) found = true; break; case value_expr_t::O_QUES: -- cgit v1.2.3