mirror of
https://github.com/adamhathcock/sharpcompress.git
synced 2026-02-10 21:22:11 +00:00
[PR #1043] [MERGED] Fix DivideByZeroException when compressing empty files with BZip2 #1466
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/adamhathcock/sharpcompress/pull/1043
Author: @Copilot
Created: 11/27/2025
Status: ✅ Merged
Merged: 11/27/2025
Merged by: @adamhathcock
Base:
master← Head:copilot/fix-divide-by-zero-exception📝 Commits (2)
cc4d281Initial plan6d73c5bFix DivideByZeroException when using BZip2 with empty files📊 Changes
2 files changed (+44 additions, -0 deletions)
View changed files
📝
src/SharpCompress/Compressors/BZip2/CBZip2OutputStream.cs(+6 -0)📝
tests/SharpCompress.Test/Zip/ZipWriterTests.cs(+38 -0)📄 Description
Writing empty files or folders to a Zip archive with BZip2 compression throws
DivideByZeroExceptioninMainSort()due to(i % (last + 1))evaluating to(i % 0)whenlast = -1.Changes
EndBlock()whenlast < 0to skip block processing for empty inputOriginal prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.