ObjectName can't point to a local variable because it is used later outside of this function.
Signed-off-by: Alex Henrie alexhenrie24@gmail.com --- dlls/combase/combase.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/dlls/combase/combase.c b/dlls/combase/combase.c index 4677972656f..a3ba3a53fe6 100644 --- a/dlls/combase/combase.c +++ b/dlls/combase/combase.c @@ -186,18 +186,16 @@ static NTSTATUS create_key(HKEY *retkey, ACCESS_MASK access, OBJECT_ATTRIBUTES * HANDLE subkey, root = attr->RootDirectory; WCHAR *buffer = attr->ObjectName->Buffer; DWORD attrs, pos = 0, i = 0, len = attr->ObjectName->Length / sizeof(WCHAR); - UNICODE_STRING str;
while (i < len && buffer[i] != '\') i++; if (i == len) return status;
attrs = attr->Attributes; - attr->ObjectName = &str;
while (i < len) { - str.Buffer = buffer + pos; - str.Length = (i - pos) * sizeof(WCHAR); + attr->ObjectName->Buffer = buffer + pos; + attr->ObjectName->Length = (i - pos) * sizeof(WCHAR); status = NtCreateKey(&subkey, access, attr, 0, NULL, 0, NULL); if (attr->RootDirectory != root) NtClose(attr->RootDirectory); if (status) return status; @@ -206,8 +204,8 @@ static NTSTATUS create_key(HKEY *retkey, ACCESS_MASK access, OBJECT_ATTRIBUTES * pos = i; while (i < len && buffer[i] != '\') i++; } - str.Buffer = buffer + pos; - str.Length = (i - pos) * sizeof(WCHAR); + attr->ObjectName->Buffer = buffer + pos; + attr->ObjectName->Length = (i - pos) * sizeof(WCHAR); attr->Attributes = attrs; status = NtCreateKey((HANDLE *)retkey, access, attr, 0, NULL, 0, NULL); if (attr->RootDirectory != root) NtClose(attr->RootDirectory);
I'd rather saved/restored ObjectName pointer, doesn't look safe to write to it.
On Mon, Dec 20, 2021 at 12:18 AM Nikolay Sivov nsivov@codeweavers.com wrote:
I'd rather saved/restored ObjectName pointer, doesn't look safe to write to it.
How about we just print the original name variable instead of trying to refer to it through attr.ObjectName. I'll send new patches.
-Alex