From b64865fbdf7d816a773df490f595ad0c48b99b63 Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Sat, 17 Aug 2019 16:30:21 +0300 Subject: [PATCH] [UDFS] Fix accessing an already freed pointer in UDFMarkAllocatedAsNotXXX() CORE-11182 --- drivers/filesystems/udfs/udf_info/extent.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/filesystems/udfs/udf_info/extent.cpp b/drivers/filesystems/udfs/udf_info/extent.cpp index db4f23fa5b8..5e507d35591 100644 --- a/drivers/filesystems/udfs/udf_info/extent.cpp +++ b/drivers/filesystems/udfs/udf_info/extent.cpp @@ -2158,6 +2158,7 @@ UDFMarkAllocatedAsNotXXX( Extent[i].extLocation = 0; Extent[i].extLength = (Extent[i].extLength & UDF_EXTENT_LENGTH_MASK) | flags; NewExtent = Extent; + Extent = NULL; AdPrint(("Alloc->Not (1) NewExtent = Extent = %x\n", NewExtent)); } else if(l < BOffs) { @@ -2211,15 +2212,17 @@ UDFMarkAllocatedAsNotXXX( if(Deallocate) UDFMarkSpaceAsXXX(Vcb, (-1), TmpExtInf.Mapping, AS_DISCARDED); // mark as free + ExtInfo->Modified = TRUE; + ExtInfo->Mapping = NewExtent; + + AdPrint(("Alloc->Not: ExtInfo %x, Extent %x\n", ExtInfo, ExtInfo->Mapping)); + if(Extent) { AdPrint(("Alloc->Not kill %x\n", Extent)); MyFreePool__(Extent); } else { AdPrint(("Alloc->Not keep %x\n", Extent)); } - ExtInfo->Modified = TRUE; - ExtInfo->Mapping = NewExtent; - AdPrint(("Alloc->Not: ExtInfo %x, Extent %x\n", ExtInfo, ExtInfo->Mapping)); return STATUS_SUCCESS; } // end UDFMarkAllocatedAsNotXXX()