about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-11-19 11:32:33 -0800
committerKartik K. Agaram <vc@akkartik.com>2015-12-15 10:20:41 -0800
commit4fb72d7511c67128faad363961cdd271dc1c7a48 (patch)
tree846a0d22600f9723a5c6671f1bca00ea2d595807
parent8a65d3b25c534376acc15703fa14a4b5e4955d6a (diff)
downloadmu-4fb72d7511c67128faad363961cdd271dc1c7a48.tar.gz
fix a crash on unknown type
-rw-r--r--031address.cc11
1 files changed, 11 insertions, 0 deletions
diff --git a/031address.cc b/031address.cc
index 040037bd..8efd5cd8 100644
--- a/031address.cc
+++ b/031address.cc
@@ -61,6 +61,13 @@ void lookup_memory(reagent& x) {
   drop_one_lookup(x);
 }
 
+:(scenario canonize_non_pointer_fails_without_crashing)
+% Hide_errors = true;
+recipe foo [
+  1:address:number <- get-address *p, x:offset
+]
+# don't crash
+
 :(after "bool types_strictly_match(reagent lhs, reagent rhs)")
   if (!canonize_type(lhs)) return false;
   if (!canonize_type(rhs)) return false;
@@ -88,6 +95,10 @@ bool canonize_type(reagent& r) {
 }
 
 void drop_address_from_type(reagent& r) {
+  if (!r.type) {
+    raise_error << "can't drop address from " << debug_string(r) << '\n' << end();
+    return;
+  }
   type_tree* tmp = r.type;
   r.type = tmp->right;
   tmp->right = NULL;