Skip to content

Commit 366edf6

Browse files
committed
Prevent leaking DiffSafeHandle on UnmatchedPathException
1 parent 1335053 commit 366edf6

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

LibGit2Sharp/Diff.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,15 @@ private DiffSafeHandle BuildDiffList(ObjectId oldTreeId, ObjectId newTreeId, Tre
322322

323323
if (explicitPathsOptions != null)
324324
{
325-
DispatchUnmatchedPaths(explicitPathsOptions, filePaths, matchedPaths);
325+
try
326+
{
327+
DispatchUnmatchedPaths(explicitPathsOptions, filePaths, matchedPaths);
328+
}
329+
catch
330+
{
331+
diffList.Dispose();
332+
throw;
333+
}
326334
}
327335

328336
DetectRenames(diffList, compareOptions);

0 commit comments

Comments
 (0)