[PATCH v2] ws2_32: Fix memory leaks on error paths in unix_gethostby* (scan-build)

Alex Henrie alexhenrie24 at gmail.com
Tue Dec 21 23:13:43 CST 2021


Signed-off-by: Alex Henrie <alexhenrie24 at gmail.com>
---
v2: Don't free before the call to hostent_from_unix
---
 dlls/ws2_32/unixlib.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/dlls/ws2_32/unixlib.c b/dlls/ws2_32/unixlib.c
index e89ebe35248..1f82aee81de 100644
--- a/dlls/ws2_32/unixlib.c
+++ b/dlls/ws2_32/unixlib.c
@@ -866,7 +866,10 @@ static NTSTATUS unix_gethostbyaddr( void *args )
         }
 
         if (!unix_host)
+        {
+            free( unix_buffer );
             return (locerr < 0 ? errno_from_unix( errno ) : host_errno_from_unix( locerr ));
+        }
 
         ret = hostent_from_unix( unix_host, params->host, params->size );
 
@@ -916,7 +919,10 @@ static NTSTATUS unix_gethostbyname( void *args )
     }
 
     if (!unix_host)
+    {
+        free( unix_buffer );
         return (locerr < 0 ? errno_from_unix( errno ) : host_errno_from_unix( locerr ));
+    }
 
     ret = hostent_from_unix( unix_host, params->host, params->size );
 
-- 
2.34.1




More information about the wine-devel mailing list