commit a0e81298366197c343aa773e4e95b0c0ef1a89b2 parent 85f5b69c494039b0a10763aa2ae952e7153eb917 Author: Alexey Yerin <yyp@disroot.org> Date: Wed, 1 Sep 2021 16:04:17 +0300 gen: add padding at the end of structs Fixes net::dial crash. Signed-off-by: Alexey Yerin <yyp@disroot.org> Diffstat:
M | src/gen.c | | | 11 | +++++++++++ |
1 file changed, 11 insertions(+), 0 deletions(-)
diff --git a/src/gen.c b/src/gen.c @@ -3024,6 +3024,17 @@ gen_data_item(struct gen_context *ctx, struct expression *expr, item->next = xcalloc(1, sizeof(struct qbe_data_item)); item = item->next; + } else { + const struct struct_field *fi = f->field; + if (fi->offset + fi->type->size + != expr->result->size) { + item->next = xcalloc(1, + sizeof(struct qbe_data_item)); + item = item->next; + item->type = QD_ZEROED; + item->zeroed = expr->result->size + - (fi->offset + fi->type->size); + } } } break;