mirror of https://git.tukaani.org/xz.git
Tests: test_index: Make it clear that my_alloc() has no integer overflows
liblzma guarantees that the product of the allocation size arguments will fit in size_t. Putting the pre-increment in the if-statement was clearly wrong although in practice it didn't matter here as the function is called only a couple of times.
This commit is contained in:
parent
12313a3b65
commit
7f865577a6
|
@ -1282,10 +1282,13 @@ my_alloc(void *opaque, size_t a, size_t b)
|
|||
{
|
||||
(void)opaque;
|
||||
|
||||
assert_true(SIZE_MAX / a >= b);
|
||||
|
||||
static unsigned count = 0;
|
||||
if (++count > 2)
|
||||
if (count >= 2)
|
||||
return NULL;
|
||||
|
||||
++count;
|
||||
return malloc(a * b);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue