stress/sizes: Fix an off-by-one issue.
Algorithmically, a size greater than 1024 ZB could access one-past-the-end of the sizes array. This couldn't really happen since SIZE_MAX is less than 1024 ZB on all platforms we support (and we pick the arguments to this function to be reasonable anyways), but it's not like there's any reason *not* to fix it, either.
This commit is contained in:
parent
dcfa6fd507
commit
7e09a57b39
@ -17,7 +17,7 @@ do_print(const char *name, size_t sz_bytes) {
|
|||||||
|
|
||||||
size_t ind = 0;
|
size_t ind = 0;
|
||||||
double sz = sz_bytes;
|
double sz = sz_bytes;
|
||||||
while (sz >= 1024 && ind < sizes_max) {
|
while (sz >= 1024 && ind < sizes_max - 1) {
|
||||||
sz /= 1024;
|
sz /= 1024;
|
||||||
ind++;
|
ind++;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user