diff --git a/reactos/dll/win32/kernel32/file/volume.c b/reactos/dll/win32/kernel32/file/volume.c index 09e07ab5883..0283def92cf 100644 --- a/reactos/dll/win32/kernel32/file/volume.c +++ b/reactos/dll/win32/kernel32/file/volume.c @@ -996,15 +996,16 @@ GetVolumeNameForVolumeMountPointW( MountPoints, BufferLength); if (!NT_SUCCESS(Status)) { - RtlFreeHeap(RtlGetProcessHeap(), 0, MountPoints); if (Status == STATUS_BUFFER_OVERFLOW) { BufferLength = MountPoints->Size; + RtlFreeHeap(RtlGetProcessHeap(), 0, MountPoints); continue; } else if (!NT_SUCCESS(Status)) { RtlFreeHeap(RtlGetProcessHeap(), 0, MountPoint); + RtlFreeHeap(RtlGetProcessHeap(), 0, MountPoints); NtClose(FileHandle); SetLastErrorByStatus(Status); return FALSE;