use calculated size for overflow tests

This greatly reduces how much these tests depend on hard-wired knowledge
about the size classes.
pull/180/head
Daniel Micay 2022-01-03 21:11:31 -05:00
parent acda766e2c
commit 13a1f578cb
2 changed files with 4 additions and 2 deletions

View File

@ -7,7 +7,8 @@ OPTNONE int main(void) {
if (!p) {
return 1;
}
*(p + 256 * 1024 + 7) = 0;
size_t size = malloc_usable_size(p);
*(p + size + 7) = 0;
free(p);
return 0;
}

View File

@ -7,7 +7,8 @@ OPTNONE int main(void) {
if (!p) {
return 1;
}
*(p + 8 + 7) ^= 1;
size_t size = malloc_usable_size(p);
*(p + size + 7) ^= 1;
free(p);
return 0;
}