mirror of
https://github.com/reactos/reactos.git
synced 2024-12-29 02:25:17 +00:00
- Free or recycle the remaining path string after a call to ObFindObject.
svn path=/trunk/; revision=8081
This commit is contained in:
parent
f6f4ac5f7b
commit
885ca2f7f3
2 changed files with 42 additions and 14 deletions
|
@ -69,6 +69,7 @@ NtCreateKey(OUT PHANDLE KeyHandle,
|
|||
if (((PKEY_OBJECT) Object)->Flags & KO_MARKED_FOR_DELETE)
|
||||
{
|
||||
ObDereferenceObject(Object);
|
||||
RtlFreeUnicodeString(&RemainingPath);
|
||||
return(STATUS_UNSUCCESSFUL);
|
||||
}
|
||||
|
||||
|
@ -83,6 +84,7 @@ NtCreateKey(OUT PHANDLE KeyHandle,
|
|||
|
||||
DPRINT("Status %x\n", Status);
|
||||
ObDereferenceObject(Object);
|
||||
RtlFreeUnicodeString(&RemainingPath);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -96,6 +98,7 @@ NtCreateKey(OUT PHANDLE KeyHandle,
|
|||
if (End != NULL)
|
||||
{
|
||||
ObDereferenceObject(Object);
|
||||
RtlFreeUnicodeString(&RemainingPath);
|
||||
return STATUS_OBJECT_NAME_NOT_FOUND;
|
||||
}
|
||||
|
||||
|
@ -124,6 +127,7 @@ NtCreateKey(OUT PHANDLE KeyHandle,
|
|||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
ObDereferenceObject(KeyObject);
|
||||
RtlFreeUnicodeString(&RemainingPath);
|
||||
return(Status);
|
||||
}
|
||||
|
||||
|
@ -159,11 +163,20 @@ NtCreateKey(OUT PHANDLE KeyHandle,
|
|||
KeLeaveCriticalRegion();
|
||||
ObDereferenceObject(KeyObject);
|
||||
ObDereferenceObject(Object);
|
||||
RtlFreeUnicodeString(&RemainingPath);
|
||||
return STATUS_UNSUCCESSFUL;
|
||||
}
|
||||
|
||||
RtlCreateUnicodeString(&KeyObject->Name,
|
||||
Start);
|
||||
if (Start == RemainingPath.Buffer)
|
||||
{
|
||||
KeyObject->Name = RemainingPath;
|
||||
}
|
||||
else
|
||||
{
|
||||
RtlCreateUnicodeString(&KeyObject->Name,
|
||||
Start);
|
||||
RtlFreeUnicodeString(&RemainingPath);
|
||||
}
|
||||
|
||||
if (KeyObject->RegistryHive == KeyObject->ParentKey->RegistryHive)
|
||||
{
|
||||
|
@ -847,9 +860,12 @@ NtOpenKey(OUT PHANDLE KeyHandle,
|
|||
if ((RemainingPath.Buffer != NULL) && (RemainingPath.Buffer[0] != 0))
|
||||
{
|
||||
ObDereferenceObject(Object);
|
||||
RtlFreeUnicodeString(&RemainingPath);
|
||||
return STATUS_OBJECT_NAME_NOT_FOUND;
|
||||
}
|
||||
|
||||
RtlFreeUnicodeString(&RemainingPath);
|
||||
|
||||
/* Fail if the key has been deleted */
|
||||
if (((PKEY_OBJECT)Object)->Flags & KO_MARKED_FOR_DELETE)
|
||||
{
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: registry.c,v 1.120 2004/01/19 16:18:33 ekohl Exp $
|
||||
/* $Id: registry.c,v 1.121 2004/02/07 17:30:14 hbirr Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -532,6 +532,7 @@ CmiConnectHive(IN POBJECT_ATTRIBUTES KeyObjectAttributes,
|
|||
if ((RemainingPath.Buffer == NULL) || (RemainingPath.Buffer[0] == 0))
|
||||
{
|
||||
ObDereferenceObject (ParentKey);
|
||||
RtlFreeUnicodeString(&RemainingPath);
|
||||
return STATUS_OBJECT_NAME_COLLISION;
|
||||
}
|
||||
|
||||
|
@ -544,6 +545,7 @@ CmiConnectHive(IN POBJECT_ATTRIBUTES KeyObjectAttributes,
|
|||
if (wcschr (SubName, L'\\') != NULL)
|
||||
{
|
||||
ObDereferenceObject (ParentKey);
|
||||
RtlFreeUnicodeString(&RemainingPath);
|
||||
return STATUS_OBJECT_NAME_NOT_FOUND;
|
||||
}
|
||||
|
||||
|
@ -563,6 +565,7 @@ CmiConnectHive(IN POBJECT_ATTRIBUTES KeyObjectAttributes,
|
|||
{
|
||||
DPRINT1 ("ObCreateObject() failed (Status %lx)\n", Status);
|
||||
ObDereferenceObject (ParentKey);
|
||||
RtlFreeUnicodeString(&RemainingPath);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -572,28 +575,37 @@ CmiConnectHive(IN POBJECT_ATTRIBUTES KeyObjectAttributes,
|
|||
NewKey->Flags = 0;
|
||||
NewKey->NumberOfSubKeys = 0;
|
||||
NewKey->SubKeys = ExAllocatePool(PagedPool,
|
||||
NewKey->KeyCell->NumberOfSubKeys * sizeof(ULONG));
|
||||
NewKey->KeyCell->NumberOfSubKeys * sizeof(ULONG));
|
||||
|
||||
if ((NewKey->SubKeys == NULL) && (NewKey->KeyCell->NumberOfSubKeys != 0))
|
||||
{
|
||||
DPRINT("NumberOfSubKeys %d\n", NewKey->KeyCell->NumberOfSubKeys);
|
||||
ObDereferenceObject (NewKey);
|
||||
ObDereferenceObject (ParentKey);
|
||||
RtlFreeUnicodeString(&RemainingPath);
|
||||
return STATUS_INSUFFICIENT_RESOURCES;
|
||||
}
|
||||
|
||||
Status = RtlCreateUnicodeString(&NewKey->Name,
|
||||
SubName);
|
||||
if (!NT_SUCCESS(Status))
|
||||
if (SubName == RemainingPath.Buffer)
|
||||
{
|
||||
DPRINT1("RtlCreateUnicodeString() failed (Status %lx)\n", Status);
|
||||
if (NewKey->SubKeys != NULL)
|
||||
{
|
||||
ExFreePool (NewKey->SubKeys);
|
||||
NewKey->Name = RemainingPath;
|
||||
}
|
||||
else
|
||||
{
|
||||
Status = RtlCreateUnicodeString(&NewKey->Name,
|
||||
SubName);
|
||||
RtlFreeUnicodeString(&RemainingPath);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1("RtlCreateUnicodeString() failed (Status %lx)\n", Status);
|
||||
if (NewKey->SubKeys != NULL)
|
||||
{
|
||||
ExFreePool (NewKey->SubKeys);
|
||||
}
|
||||
ObDereferenceObject (NewKey);
|
||||
ObDereferenceObject (ParentKey);
|
||||
return STATUS_INSUFFICIENT_RESOURCES;
|
||||
}
|
||||
ObDereferenceObject (NewKey);
|
||||
ObDereferenceObject (ParentKey);
|
||||
return STATUS_INSUFFICIENT_RESOURCES;
|
||||
}
|
||||
|
||||
CmiAddKeyToList (ParentKey, NewKey);
|
||||
|
|
Loading…
Reference in a new issue