[PATCH 0/1] MR2109: setupapi: Fix memory leak on realloc failure in RetreiveFileSecurity.
From: Alex Henrie <alexhenrie24(a)gmail.com> --- dlls/setupapi/misc.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/dlls/setupapi/misc.c b/dlls/setupapi/misc.c index f9d34b5353d..5a4b899dc9d 100644 --- a/dlls/setupapi/misc.c +++ b/dlls/setupapi/misc.c @@ -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, -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/2109
participants (2)
-
Alex Henrie -
Alex Henrie (@alexhenrie)