]> git.ipfire.org Git - thirdparty/systemd.git/commit
compress: prevent divide-by-zero when no data is read (#37706)
authorAlex <alexguo1023@gmail.com>
Tue, 3 Jun 2025 01:51:00 +0000 (21:51 -0400)
committerGitHub <noreply@github.com>
Tue, 3 Jun 2025 01:51:00 +0000 (10:51 +0900)
commit2584f745e0509472e68449bd81c60c26056d514a
treebb5826bfdc4165d5bc6bcd04079842c338815717
parent1a596054a0f937bfc244580f07510759a0e45657
compress: prevent divide-by-zero when no data is read (#37706)

If the first call to `loop_read()` returns 0 (no input), `total_in`
remains 0, causing `total_out/total_in` to potential divide by zero.

We add a check before logging the compression ratio to skip the
percentage calculation when total_in is zero.

Co-authored-by: jinyaoguo <guo846@purdue.edu>
src/basic/compress.c