From e7cb34ec471b9a212ed9d7b067c5f0bd5282c89f Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Mon, 9 Dec 2019 20:02:39 -0800 Subject: structs: bugfix: crash in static slot inheritance. * struct.c (make_struct_type): When a struct defines a static slot that exists as an instancee slot in the supertype, there is a crash. This is because the code assumes that the supertype's slot is static. The index value m ends up negative due to subtracting STATIC_SLOT_BASE from an instance slot index, and so the code tries to copy the value of a negatively indexed static slot from the supertype into the new static slot. We can fix this by not doing the copy when a negative index has been calculated. That way we treat the situation as if the supertype didn't have that slot at all. --- struct.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'struct.c') diff --git a/struct.c b/struct.c index a8d1f373..c44dbc7a 100644 --- a/struct.c +++ b/struct.c @@ -370,7 +370,7 @@ val make_struct_type(val name, val super, ss->home_type = stype; ss->home_offs = n; ss->home = &ss->store; - ss->store = if2(msl, stslot_place(&su->stslot[m])); + ss->store = if2(m >= 0, stslot_place(&su->stslot[m])); } else { *ss = su->stslot[m]; ss->store = nil; -- cgit v1.2.3