Author: pschweitzer
Date: Wed Apr 13 19:52:42 2016
New Revision: 71155
URL:
http://svn.reactos.org/svn/reactos?rev=71155&view=rev
Log:
[NTFS]
Don't leak memory in case of failures in NtfsReadDisk().
Based on a patch by Trevor Thompson.
CORE-10998
Modified:
trunk/reactos/drivers/filesystems/ntfs/blockdev.c
Modified: trunk/reactos/drivers/filesystems/ntfs/blockdev.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/ntfs/b…
==============================================================================
--- trunk/reactos/drivers/filesystems/ntfs/blockdev.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/ntfs/blockdev.c [iso-8859-1] Wed Apr 13 19:52:42
2016
@@ -87,6 +87,12 @@
if (Irp == NULL)
{
DPRINT("IoBuildSynchronousFsdRequest failed\n");
+
+ if (AllocatedBuffer)
+ {
+ ExFreePoolWithTag(ReadBuffer, TAG_NTFS);
+ }
+
return STATUS_INSUFFICIENT_RESOURCES;
}
@@ -108,9 +114,13 @@
Status = IoStatus.Status;
}
- if (NT_SUCCESS(Status) && AllocatedBuffer)
- {
- RtlCopyMemory(Buffer, ReadBuffer + (StartingOffset - RealReadOffset), Length);
+ if (AllocatedBuffer)
+ {
+ if (NT_SUCCESS(Status))
+ {
+ RtlCopyMemory(Buffer, ReadBuffer + (StartingOffset - RealReadOffset),
Length);
+ }
+
ExFreePoolWithTag(ReadBuffer, TAG_NTFS);
}