In ga_get_win_product_name() a handle to Registry key was open but not closed. In this patch the handle is closed as part of the free routine.
Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=1929144 Signed-off-by: Basil Salman <ba...@daynix.com> Signed-off-by: Basil Salman <bsal...@redhat.com> --- qga/commands-win32.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/qga/commands-win32.c b/qga/commands-win32.c index d51833ef15..8cea3ec0f8 100644 --- a/qga/commands-win32.c +++ b/qga/commands-win32.c @@ -2229,7 +2229,7 @@ static char *ga_get_win_name(OSVERSIONINFOEXW const *os_version, bool id) static char *ga_get_win_product_name(Error **errp) { - HKEY key = NULL; + HKEY key = INVALID_HANDLE_VALUE; DWORD size = 128; char *result = g_malloc0(size); LONG err = ERROR_SUCCESS; @@ -2239,7 +2239,8 @@ static char *ga_get_win_product_name(Error **errp) &key); if (err != ERROR_SUCCESS) { error_setg_win32(errp, err, "failed to open registry key"); - goto fail; + g_free(result); + return NULL; } err = RegQueryValueExA(key, "ProductName", NULL, NULL, @@ -2260,9 +2261,12 @@ static char *ga_get_win_product_name(Error **errp) goto fail; } + RegCloseKey(key); return result; fail: + if (key != INVALID_HANDLE_VALUE) { + RegCloseKey(key); + } g_free(result); return NULL; } -- 2.17.2