[KERNEL32]
authorPierre Schweitzer <pierre@reactos.org>
Sun, 26 Oct 2014 21:09:07 +0000 (21:09 +0000)
committerPierre Schweitzer <pierre@reactos.org>
Sun, 26 Oct 2014 21:09:07 +0000 (21:09 +0000)
Prevent a use-after-free issue in GetVolumeNameForVolumeMountPointW()

svn path=/trunk/; revision=65034

reactos/dll/win32/kernel32/client/file/mntpoint.c

index af0ae94..c6beae0 100644 (file)
@@ -118,14 +118,15 @@ GetVolumeNameForVolumeMountPointW(IN LPCWSTR VolumeMountPoint,
                                      NULL, 0, MountDevName, BufferLength);
       if (!NT_SUCCESS(Status))
       {
-         RtlFreeHeap(GetProcessHeap(), 0, MountDevName);
          if (Status == STATUS_BUFFER_OVERFLOW)
          {
             BufferLength = sizeof(MOUNTDEV_NAME) + MountDevName->NameLength;
+            RtlFreeHeap(GetProcessHeap(), 0, MountDevName);
             continue;
          }
          else
          {
+            RtlFreeHeap(GetProcessHeap(), 0, MountDevName);
             NtClose(FileHandle);
             BaseSetLastNTError(Status);
             return FALSE;