From 2153e7eb25d0ffd2b4af0776df8e089e7c503687 Mon Sep 17 00:00:00 2001
From: huangkai <huangkai101@huawei.com>
Date: Tue, 2 Aug 2022 16:26:13 +0800
Subject: [PATCH 16/22] virNWFilterObjListFree: Prevent null pointer derefernce

Allow virNWFilterObjListFree to be called with a NULL argument.
This enables a later patch to use virNWFilterObjListFree as a
cleanup function safely, as it is a no-op if virNWFilterObj was
not yet initialized.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
---
 src/conf/virnwfilterobj.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/conf/virnwfilterobj.c b/src/conf/virnwfilterobj.c
index c9e224061d..cc59c0ea9d 100644
--- a/src/conf/virnwfilterobj.c
+++ b/src/conf/virnwfilterobj.c
@@ -108,6 +108,11 @@ void
 virNWFilterObjListFree(virNWFilterObjListPtr nwfilters)
 {
     size_t i;
+
+    if (!nwfilters) {
+        return;
+    }
+
     for (i = 0; i < nwfilters->count; i++)
         virNWFilterObjFree(nwfilters->objs[i]);
     VIR_FREE(nwfilters->objs);
-- 
2.33.0

