-
Notifications
You must be signed in to change notification settings - Fork 499
Fix ArgumentNullException when disposing RarArchive with damaged archives #1025
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix ArgumentNullException when disposing RarArchive with damaged archives #1025
Conversation
Co-authored-by: adamhathcock <527620+adamhathcock@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes an ArgumentNullException that occurs when disposing a RarArchive after processing a damaged archive. The issue arises because the window field may be null when Dispose() is called, but the code attempts to return it to the ArrayPool without checking for null first.
- Added defensive null check in
UnpackV1.Unpack.Dispose()before returning the window buffer to the ArrayPool - Aligns with existing null-check patterns used in
RarVM.cs,LzOutWindow.cs, andUnpackV2017
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
When disposing a
RarArchiveafter processing a damaged archive,ArrayPool<byte>.Shared.Return(window)throwsArgumentNullExceptionbecause thewindowfield may be null.Changes
UnpackV1.Unpack.Dispose()before returning the window buffer to the array poolUnpackV2017implementationOriginal prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.