History

bcheck: add structs to local regions

int test() { struct { int i; } s = { 42 }; return s.i; // bound checked }

Pavlas, Zdenek committed 10 years ago

Commit 550e8611 parent cdf715a1 file · +2 −2Browse files

Unified · Split

tccgen.c+2−2
@@ -6234,7 +6234,7 @@ static void decl_initializer_alloc(CType *type, AttributeDef *ad, int r, · 6233 unmodified lines
62346234 if ((r & VT_VALMASK) == VT_LOCAL) {
62356235 sec = NULL;
62366236 #ifdef CONFIG_TCC_BCHECK
6237− if (tcc_state->do_bounds_check && (type->t & VT_ARRAY)) {
6237+ if (tcc_state->do_bounds_check && ((type->t & VT_ARRAY) || (type->t & VT_BTYPE) == VT_STRUCT)) {
62386238 loc--;
62396239 }
62406240 #endif
@@ -6244,7 +6244,7 @@ static void decl_initializer_alloc(CType *type, AttributeDef *ad, int r, · 3 unmodified lines
62446244 /* handles bounds */
62456245 /* XXX: currently, since we do only one pass, we cannot track
62466246 '&' operators, so we add only arrays */
6247− if (tcc_state->do_bounds_check && (type->t & VT_ARRAY)) {
6247+ if (tcc_state->do_bounds_check && ((type->t & VT_ARRAY) || (type->t & VT_BTYPE) == VT_STRUCT)) {
62486248 addr_t *bounds_ptr;
62496249 /* add padding between regions */
62506250 loc--;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t