[NTFS] Don't leak attributes contextes in the btree management functions

CID 1427030, 1427062
This commit is contained in:
Pierre Schweitzer 2017-12-31 10:21:42 +01:00
parent 391056ba22
commit 9d9cce2838
No known key found for this signature in database
GPG key ID: 7545556C3D585B0B

View file

@ -732,7 +732,8 @@ CreateBTreeFromIndex(PDEVICE_EXTENSION Vcb,
{ {
DPRINT1("Filesystem corruption detected!\n"); DPRINT1("Filesystem corruption detected!\n");
DestroyBTree(Tree); DestroyBTree(Tree);
return STATUS_FILE_CORRUPT_ERROR; Status = STATUS_FILE_CORRUPT_ERROR;
goto Cleanup;
} }
// Start at the first node entry // Start at the first node entry
@ -749,7 +750,8 @@ CreateBTreeFromIndex(PDEVICE_EXTENSION Vcb,
{ {
DPRINT1("ERROR: Couldn't allocate memory for next key!\n"); DPRINT1("ERROR: Couldn't allocate memory for next key!\n");
DestroyBTree(Tree); DestroyBTree(Tree);
return STATUS_INSUFFICIENT_RESOURCES; Status = STATUS_INSUFFICIENT_RESOURCES;
goto Cleanup;
} }
RootNode->KeyCount++; RootNode->KeyCount++;
@ -763,7 +765,8 @@ CreateBTreeFromIndex(PDEVICE_EXTENSION Vcb,
{ {
DPRINT1("ERROR: Couldn't allocate memory for next key!\n"); DPRINT1("ERROR: Couldn't allocate memory for next key!\n");
DestroyBTree(Tree); DestroyBTree(Tree);
return STATUS_INSUFFICIENT_RESOURCES; Status = STATUS_INSUFFICIENT_RESOURCES;
goto Cleanup;
} }
RtlZeroMemory(NextKey, sizeof(B_TREE_KEY)); RtlZeroMemory(NextKey, sizeof(B_TREE_KEY));
@ -786,7 +789,8 @@ CreateBTreeFromIndex(PDEVICE_EXTENSION Vcb,
{ {
DPRINT1("ERROR: Couldn't create child node!\n"); DPRINT1("ERROR: Couldn't create child node!\n");
DestroyBTree(Tree); 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"); DPRINT1("ERROR: Couldn't create child node!\n");
DestroyBTree(Tree); DestroyBTree(Tree);
return STATUS_NOT_IMPLEMENTED; Status = STATUS_NOT_IMPLEMENTED;
goto Cleanup;
} }
} }
@ -822,11 +827,13 @@ CreateBTreeFromIndex(PDEVICE_EXTENSION Vcb,
} }
*NewTree = Tree; *NewTree = Tree;
Status = STATUS_SUCCESS;
Cleanup:
if (IndexAllocationContext) if (IndexAllocationContext)
ReleaseAttributeContext(IndexAllocationContext); ReleaseAttributeContext(IndexAllocationContext);
return STATUS_SUCCESS; return Status;
} }
/** /**
@ -1242,6 +1249,7 @@ UpdateIndexAllocation(PDEVICE_EXTENSION DeviceExt,
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
DPRINT1("ERROR: Failed to add index bitmap!\n"); DPRINT1("ERROR: Failed to add index bitmap!\n");
ReleaseAttributeContext(IndexAllocationContext);
return Status; return Status;
} }
@ -2019,4 +2027,4 @@ SplitBTreeNode(PB_TREE Tree,
#endif #endif
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }