diff options
author | Michael Forney <mforney@mforney.org> | 2019-04-15 01:40:44 -0700 |
---|---|---|
committer | Michael Forney <mforney@mforney.org> | 2019-04-15 01:47:11 -0700 |
commit | 1891c1c81b7ed607d75eaaa4fde6d20121941085 (patch) | |
tree | 9c39ac401caf900c4dbd75e01bacd9fd965ee583 /decl.c | |
parent | fca0b26275a82c480a5286c281834dad6887b410 (diff) |
decl: Fix uninitialized access with unnamed bit-fields
Diffstat (limited to 'decl.c')
-rw-r--r-- | decl.c | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -57,7 +57,7 @@ enum funcspec { struct structbuilder { struct type *type; struct member **last; - int bits; /* number of bits remaining in the last byte */ + unsigned bits; /* number of bits remaining in the last byte */ }; struct decl * @@ -687,13 +687,13 @@ addmember(struct structbuilder *b, struct qualtype mt, char *name, int align, ui t->size = end; b->bits = 0; } - if (width) { + if (name) { m->offset = ALIGNDOWN(t->size - !!b->bits, mt.type->size); m->bits.before = (t->size - m->offset) * 8 - b->bits; m->bits.after = mt.type->size * 8 - width - m->bits.before; - t->size += (width - b->bits + 7) / 8; - b->bits = m->bits.after % 8; } + t->size += (width - b->bits + 7) / 8; + b->bits = (b->bits - width) % 8; align = mt.type->align; } if (t->align < align) |