[PATCH v3 0/1] MR8918: wineboot: Fix a memory leak in create_computer_name_keys.
If the canonical hostname was "localhost", the address info was not freed. Don't bother checking whether ai_canonname is NULL because if there is no canonical name, getaddrinfo must set ai_canonname to the input name. Fixes: ca5a6d07dc92ba631b178ec175e6b3fd5295e3d6 -- v3: wineboot: Fix a memory leak in create_computer_name_keys. https://gitlab.winehq.org/wine/wine/-/merge_requests/8918
From: Alex Henrie <alexhenrie24(a)gmail.com> If the canonical hostname was "localhost", the address info was not freed. Don't bother checking whether ai_canonname is NULL because if there is no canonical name, getaddrinfo must set ai_canonname to the input name. Fixes: ca5a6d07dc92ba631b178ec175e6b3fd5295e3d6 --- programs/wineboot/wineboot.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/programs/wineboot/wineboot.c b/programs/wineboot/wineboot.c index 8359e5d4c44..36e715c5f19 100644 --- a/programs/wineboot/wineboot.c +++ b/programs/wineboot/wineboot.c @@ -833,15 +833,16 @@ static void create_computer_name_keys(void) if (gethostname( buffer, sizeof(buffer) )) return; hints.ai_flags = AI_CANONNAME; - if (!getaddrinfo( buffer, NULL, &hints, &res ) && - res->ai_canonname && strcasecmp(res->ai_canonname, "localhost") != 0) + if (getaddrinfo( buffer, NULL, &hints, &res ) != 0) + res = NULL; + else if (strcasecmp( res->ai_canonname, "localhost" ) != 0) name = res->ai_canonname; dot = strchr( name, '.' ); if (dot) *dot++ = 0; else dot = name + strlen(name); SetComputerNameExA( ComputerNamePhysicalDnsDomain, dot ); SetComputerNameExA( ComputerNamePhysicalDnsHostname, name ); - if (name != buffer) freeaddrinfo( res ); + if (res) freeaddrinfo( res ); if (RegOpenKeyW( HKEY_LOCAL_MACHINE, L"System\\CurrentControlSet\\Control\\ComputerName", &key )) return; -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/8918
This merge request was approved by Jinoh Kang. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/8918
participants (3)
-
Alex Henrie -
Alex Henrie (@alexhenrie) -
Jinoh Kang (@iamahuman)