setupapi: Fix memory leak on realloc failure in RetreiveFileSecurity.

This commit is contained in:
Alex Henrie 2023-02-03 22:47:37 -07:00 committed by Alexandre Julliard
parent 7077c5bcab
commit 002057543d

View file

@ -740,7 +740,7 @@ fail:;
DWORD WINAPI RetreiveFileSecurity(LPCWSTR lpFileName,
PSECURITY_DESCRIPTOR *pSecurityDescriptor)
{
PSECURITY_DESCRIPTOR SecDesc;
SECURITY_DESCRIPTOR *SecDesc, *NewSecDesc;
DWORD dwSize = 0x100;
DWORD dwError;
@ -763,9 +763,13 @@ DWORD WINAPI RetreiveFileSecurity(LPCWSTR lpFileName,
return dwError;
}
SecDesc = MyRealloc(SecDesc, dwSize);
if (SecDesc == NULL)
NewSecDesc = MyRealloc(SecDesc, dwSize);
if (NewSecDesc == NULL)
{
MyFree(SecDesc);
return ERROR_NOT_ENOUGH_MEMORY;
}
SecDesc = NewSecDesc;
if (GetFileSecurityW(lpFileName, OWNER_SECURITY_INFORMATION |
GROUP_SECURITY_INFORMATION | DACL_SECURITY_INFORMATION,