From 8d529bed1a43007db8f083c69d270c67ccb40773 Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Tue, 28 Dec 2010 19:19:53 -0800 Subject: Fix a few segfaults --- evaluator.cpp | 3 +++ value.cpp | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/evaluator.cpp b/evaluator.cpp index c5721ae..954a488 100644 --- a/evaluator.cpp +++ b/evaluator.cpp @@ -13,6 +13,9 @@ evaluator::evaluate( value * l, value * r) { + if (!l || !r) { + return default_evaluate(l, r); + } enum value_type l_type = l->get_type(); enum value_type r_type = r->get_type(); switch(l_type) { diff --git a/value.cpp b/value.cpp index bc7a8b8..1201344 100644 --- a/value.cpp +++ b/value.cpp @@ -31,7 +31,9 @@ tree_value::simplify() if (!m_evaluator) { return this->clone(); } - return m_evaluator->evaluate(m_lchild->simplify(), m_rchild->simplify()); + return m_evaluator->evaluate( + m_lchild ? m_lchild->simplify() : NULL, + m_rchild ? m_rchild->simplify() : NULL); } value * -- cgit v1.2.3