summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Stellard <tstellar@gmail.com>2010-12-28 19:19:53 -0800
committerTom Stellard <tstellar@gmail.com>2010-12-28 19:19:53 -0800
commit8d529bed1a43007db8f083c69d270c67ccb40773 (patch)
tree3677453685638337acd6d67f558f84d655ea099c
parentef91611ca9f13a112b66b55ed81d70490801b58f (diff)
Fix a few segfaults
-rw-r--r--evaluator.cpp3
-rw-r--r--value.cpp4
2 files changed, 6 insertions, 1 deletions
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 *