https://git.reactos.org/?p=reactos.git;a=commitdiff;h=9d9cce2838e2f277381810...
commit 9d9cce2838e2f2773818108b3cfe6be6c3e482cd Author: Pierre Schweitzer pierre@reactos.org AuthorDate: Sun Dec 31 10:21:42 2017 +0100
[NTFS] Don't leak attributes contextes in the btree management functions
CID 1427030, 1427062 --- drivers/filesystems/ntfs/btree.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-)
diff --git a/drivers/filesystems/ntfs/btree.c b/drivers/filesystems/ntfs/btree.c index 9fb1b29c0f..35a6eb6cd0 100644 --- a/drivers/filesystems/ntfs/btree.c +++ b/drivers/filesystems/ntfs/btree.c @@ -732,7 +732,8 @@ CreateBTreeFromIndex(PDEVICE_EXTENSION Vcb, { DPRINT1("Filesystem corruption detected!\n"); DestroyBTree(Tree); - return STATUS_FILE_CORRUPT_ERROR; + Status = STATUS_FILE_CORRUPT_ERROR; + goto Cleanup; }
// Start at the first node entry @@ -749,7 +750,8 @@ CreateBTreeFromIndex(PDEVICE_EXTENSION Vcb, { DPRINT1("ERROR: Couldn't allocate memory for next key!\n"); DestroyBTree(Tree); - return STATUS_INSUFFICIENT_RESOURCES; + Status = STATUS_INSUFFICIENT_RESOURCES; + goto Cleanup; }
RootNode->KeyCount++; @@ -763,7 +765,8 @@ CreateBTreeFromIndex(PDEVICE_EXTENSION Vcb, { DPRINT1("ERROR: Couldn't allocate memory for next key!\n"); DestroyBTree(Tree); - return STATUS_INSUFFICIENT_RESOURCES; + Status = STATUS_INSUFFICIENT_RESOURCES; + goto Cleanup; }
RtlZeroMemory(NextKey, sizeof(B_TREE_KEY)); @@ -786,7 +789,8 @@ CreateBTreeFromIndex(PDEVICE_EXTENSION Vcb, { DPRINT1("ERROR: Couldn't create child node!\n"); DestroyBTree(Tree); - return STATUS_NOT_IMPLEMENTED; + Status = STATUS_NOT_IMPLEMENTED; + goto Cleanup; } }
@@ -813,7 +817,8 @@ CreateBTreeFromIndex(PDEVICE_EXTENSION Vcb, { DPRINT1("ERROR: Couldn't create child node!\n"); DestroyBTree(Tree); - return STATUS_NOT_IMPLEMENTED; + Status = STATUS_NOT_IMPLEMENTED; + goto Cleanup; } }
@@ -822,11 +827,13 @@ CreateBTreeFromIndex(PDEVICE_EXTENSION Vcb, }
*NewTree = Tree; + Status = STATUS_SUCCESS;
+Cleanup: if (IndexAllocationContext) ReleaseAttributeContext(IndexAllocationContext);
- return STATUS_SUCCESS; + return Status; }
/** @@ -1242,6 +1249,7 @@ UpdateIndexAllocation(PDEVICE_EXTENSION DeviceExt, if (!NT_SUCCESS(Status)) { DPRINT1("ERROR: Failed to add index bitmap!\n"); + ReleaseAttributeContext(IndexAllocationContext); return Status; }
@@ -2019,4 +2027,4 @@ SplitBTreeNode(PB_TREE Tree, #endif
return STATUS_SUCCESS; -} \ No newline at end of file +}