[PR #1139] Fix BinaryReader disposal in TarArchive.IsTarFileAsync #1578

Closed
opened 2026-01-29 22:21:12 +00:00 by claunia · 0 comments
Owner

Original Pull Request: https://github.com/adamhathcock/sharpcompress/pull/1139

State: closed
Merged: No


The IsTarFileAsync method creates a BinaryReader on line 177 but doesn't dispose it, causing a resource leak.

Changes:

  • Wrap BinaryReader in a using statement in TarArchive.IsTarFileAsync to ensure proper disposal
  • Mirror the disposal pattern already used in the synchronous IsTarFile method on line 157
// Before
var reader = new BinaryReader(stream);
var readSucceeded = tarHeader.Read(reader);

// After  
using var reader = new BinaryReader(stream);
var readSucceeded = tarHeader.Read(reader);

💡 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.

**Original Pull Request:** https://github.com/adamhathcock/sharpcompress/pull/1139 **State:** closed **Merged:** No --- The `IsTarFileAsync` method creates a `BinaryReader` on line 177 but doesn't dispose it, causing a resource leak. **Changes:** - Wrap `BinaryReader` in a `using` statement in `TarArchive.IsTarFileAsync` to ensure proper disposal - Mirror the disposal pattern already used in the synchronous `IsTarFile` method on line 157 ```csharp // Before var reader = new BinaryReader(stream); var readSucceeded = tarHeader.Read(reader); // After using var reader = new BinaryReader(stream); var readSucceeded = tarHeader.Read(reader); ``` <!-- START COPILOT CODING AGENT TIPS --> --- 💡 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](https://gh.io/copilot-coding-agent-tips) in the docs.
claunia added the pull-request label 2026-01-29 22:21:12 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/sharpcompress#1578