Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
darray.h: avoid UB when decrementing zero pointer
Sometimes the `&(arr).item[(arr).size]` is a zero pointer. In these cases decrementing this pointer aka `i` results in something like 0xfffffff8. This is UB, and UB sanitizer in particular reports it as ../iscsi/tcmu-runner/libtcmu.c:563:2: runtime error: pointer index expression with base 0x000000000000 overflowed to 0xfffffffffffffff8 In these cases size is `zero` as well, so fix this by simply not running the cycle when the `size` is zero. Signed-off-by: Konstantin Kharlamov <[email protected]>
- Loading branch information