Skip to content

Commit cad5277

Browse files
authored
Fix: Fixed NullReferenceException with ShellFileOperations2 (#16160)
1 parent 194a9ee commit cad5277

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/Files.App/Utils/Shell/ShellFileOperations2.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace Vanara.Windows.Shell;
1111
public class ShellFileOperations2 : IDisposable
1212
{
1313
private const OperationFlags defaultOptions = OperationFlags.AllowUndo | OperationFlags.NoConfirmMkDir;
14-
private bool disposedValue = false;
14+
private int disposedValue = 0;
1515
private IFileOperation op;
1616
private OperationFlags opFlags = defaultOptions;
1717
private HWND owner;
@@ -569,7 +569,7 @@ public void QueueRenameOperation(IEnumerable<ShellItem> sourceItems, string newN
569569
/// <param name="disposing"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
570570
protected virtual void Dispose(bool disposing)
571571
{
572-
if (!disposedValue)
572+
if (Interlocked.CompareExchange(ref disposedValue, 1, 0) == 0)
573573
{
574574
if (disposing)
575575
{
@@ -582,7 +582,6 @@ protected virtual void Dispose(bool disposing)
582582
}
583583

584584
op = null;
585-
disposedValue = true;
586585
}
587586
}
588587

0 commit comments

Comments
 (0)