Alex Henrie : setupapi: Fix memory leak on realloc failure in RetreiveFileSecurity.
Module: wine Branch: master Commit: 002057543dc70b9281c609b9e7858317e0f32c54 URL: https://gitlab.winehq.org/wine/wine/-/commit/002057543dc70b9281c609b9e785831... Author: Alex Henrie <alexhenrie24(a)gmail.com> Date: Fri Feb 3 22:47:37 2023 -0700 setupapi: Fix memory leak on realloc failure in RetreiveFileSecurity. --- 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,
participants (1)
-
Alexandre Julliard