mirror of https://github.com/xzeldon/htop.git
CGroupUtils: avoid unsigned integer underflow
Do not underflow count at the last iteration, which triggers UBSAN when using -fsanitize=unsigned-integer-overflow. This is useful as those underflows can be a result of a flawed counting logic (e.g. a counter gets reduced more than increased).
This commit is contained in:
parent
ff0ea41c86
commit
61c9fe44a3
|
@ -33,7 +33,7 @@ static bool StrBuf_putc_write(StrBuf_state* p, char c) {
|
|||
}
|
||||
|
||||
static bool StrBuf_putsn(StrBuf_state* p, StrBuf_putc_t w, const char* s, size_t count) {
|
||||
while (count--)
|
||||
for (; count; count--)
|
||||
if (!w(p, *s++))
|
||||
return false;
|
||||
|
||||
|
|
Loading…
Reference in New Issue