Fix NullReferenceException when extracting 7z empty-stream entries#1219
Conversation
Co-authored-by: adamhathcock <527620+adamhathcock@users.noreply.github.com>
Co-authored-by: adamhathcock <527620+adamhathcock@users.noreply.github.com>
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Files Reviewed (3 files)
|
|
Hi @adamhathcock, thanks for getting this fix merged quickly (especially on the release branch). I noticed PR #1219 is effectively a rework/port of my original PR #1218 (“redo #1218 but on release”), and #1218 ended up closed without attribution carrying over. Also, as a factual detail, the reproduction test data file 7Zip.EmptyStream.7z used here is the exact file I provided in #1218. Would you mind adding a short credit/reference for traceability? For example, adding a line to the PR description like: Thanks! |
|
I wasn't trying to not credit you, I just let the robots do their thing referencing your PR but on the Originally contributed by @YoshihiroIto in #1218 (ported to release in #1219). |
|
Hi @adamhathcock, Thanks for clarifying — much appreciated! |
Extracting 7z archives containing zero-byte files throws
NullReferenceExceptioninSevenZipArchive.GetEntryStream(). Empty-stream entries (files withHasStream == false) haveFolder = null, but the code dereferencedfolder!without checking.Changes
SevenZipArchive.GetEntryStream()to returnStream.Nullfor empty-stream entries, consistent with directory handling7Zip.EmptyStream.7ztest archive (4 empty files) and verification testEmpty-stream entries are a valid 7z construct where files contain no compressed data. The
Folderproperty is null for such entries by design (seeSevenZipFilePartconstructor).Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.