]> git.ipfire.org Git - thirdparty/libvirt.git/commit
esx: Fix @doms pointer steal in esxConnectListAllDomains()
authorMichal Privoznik <mprivozn@redhat.com>
Wed, 24 Mar 2021 09:33:45 +0000 (10:33 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Wed, 24 Mar 2021 12:57:51 +0000 (13:57 +0100)
commitcebd40590c406e613bedde63a88112be1bc0b546
tree6b2e5bb9829936e39452ac2b7d9280a8547723a5
parent969b8270359d8859c322d9d6f110571f45148285
esx: Fix @doms pointer steal in esxConnectListAllDomains()

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@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
src/esx/esx_driver.c