The ESX implementation of virConnectListAllDomains() follows pretty much implementations in other drivers: it has local array of virDomainPtr-s which (if requested by caller) is filled by actual domains or not (if the caller is interested only in the count of domains). Anyway, in case of the former, the passed @domains argument is set to the local array, which is then set to NULL to prevent it from freeing under cleanup label. Pretty standard pattern. Except, the local array is set to NULL always. Even if the local array is not stolen. Fortunately, this doesn't lead to a memory leak, because if caller is not interested in the array, none is allocated. But it doesn't set good example and also breaks my spatch rules. Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx> --- src/esx/esx_driver.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c index 21705ef6e3..1c68776c18 100644 --- a/src/esx/esx_driver.c +++ b/src/esx/esx_driver.c @@ -4929,9 +4929,10 @@ esxConnectListAllDomains(virConnectPtr conn, doms[count++] = dom; } - if (doms) + if (doms) { *domains = doms; - doms = NULL; + doms = NULL; + } ret = count; cleanup: -- 2.26.2