[PATCH 2/4] lxc: Allow NULL argument to lxcDomainDefNamespaceFree()

Michal Privoznik mprivozn at redhat.com
Wed Dec 16 21:12:59 UTC 2020


As all other free functions, NULL should be accepted. Even though
there currently is no caller that would pass NULL, there will be
in future patches.

Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
---
 src/lxc/lxc_domain.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/lxc/lxc_domain.c b/src/lxc/lxc_domain.c
index df60519fca..707262336b 100644
--- a/src/lxc/lxc_domain.c
+++ b/src/lxc/lxc_domain.c
@@ -195,6 +195,10 @@ lxcDomainDefNamespaceFree(void *nsdata)
 {
     size_t i;
     lxcDomainDefPtr lxcDef = nsdata;
+
+    if (!lxcDef)
+        return;
+
     for (i = 0; i < VIR_LXC_DOMAIN_NAMESPACE_LAST; i++)
         g_free(lxcDef->ns_val[i]);
     g_free(nsdata);
-- 
2.26.2




More information about the libvir-list mailing list