lib: fix memory leak of query_kvm in guestfs_int_platform_has_kvm (#316)

The string allocated by generic_qmp_test via safe_strdup is passed to
parse_has_kvm but never freed afterwards, leaking memory on every KVM
capability check. Use CLEANUP_FREE to ensure automatic cleanup.

Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
shivanayak
2026-03-09 22:52:27 +05:30
committed by GitHub
parent 25c321a8fd
commit a47c923b05

View File

@@ -193,7 +193,7 @@ parse_has_kvm (guestfs_h *g, const char *json)
int int
guestfs_int_platform_has_kvm (guestfs_h *g) guestfs_int_platform_has_kvm (guestfs_h *g)
{ {
char *query_kvm; CLEANUP_FREE char *query_kvm = NULL;
if (generic_qmp_test (g, "query-kvm", &query_kvm) == -1) if (generic_qmp_test (g, "query-kvm", &query_kvm) == -1)
return -1; return -1;