harec

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit f11c58712d65ee84eba70534b26356bf456cf3db
parent e2343e7755256f7fa08020b4d674575ab65de424
Author: Bor Grošelj Simić <bor.groseljsimic@telemach.net>
Date:   Wed,  2 Feb 2022 22:13:31 +0100

avoid SIGFPE when attempting to initialize an invalid tuple

Signed-off-by: Bor Grošelj Simić <bor.groseljsimic@telemach.net>

Diffstat:
Msrc/type_store.c | 15++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/src/type_store.c b/src/type_store.c @@ -547,14 +547,19 @@ tuple_init_from_atype(struct type_store *store, struct dimensions memb = {0}; if (type) { memb = _type_store_lookup_atype(store, &cur->type, atuple->type); + if (memb.size == 0 || memb.align == 0) { + error(store->check_context, atuple->type->loc, + "Tuple member types must have nonzero size and alignment"); + return dim; + } cur->offset = dim.size % memb.align + dim.size; } else { memb = _type_store_lookup_atype(store, NULL, atuple->type); - } - if (memb.size == 0) { - error(store->check_context, atuple->type->loc, - "Type of size zero cannot be a tuple member"); - continue; + if (memb.size == 0 || memb.align == 0) { + error(store->check_context, atuple->type->loc, + "Tuple member types must have nonzero size and alignment"); + return dim; + } } dim.size += dim.size % memb.align + memb.size; if (dim.align < memb.align) {