summaryrefslogtreecommitdiffstats
path: root/struct.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2019-12-09 20:02:39 -0800
committerKaz Kylheku <kaz@kylheku.com>2019-12-09 20:02:39 -0800
commite7cb34ec471b9a212ed9d7b067c5f0bd5282c89f (patch)
tree4d3a19b15d5c6b448a7d79e5cc256a253bdcad67 /struct.c
parent6cf10451395c20fad177704a3b5032106d083b88 (diff)
downloadtxr-e7cb34ec471b9a212ed9d7b067c5f0bd5282c89f.tar.gz
txr-e7cb34ec471b9a212ed9d7b067c5f0bd5282c89f.tar.bz2
txr-e7cb34ec471b9a212ed9d7b067c5f0bd5282c89f.zip
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.
Diffstat (limited to 'struct.c')
-rw-r--r--struct.c2
1 files changed, 1 insertions, 1 deletions
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;