diff mbox series

[22/47] libsemanage: free ibdev names in semanage_ibendport_validate_local()

Message ID 20241111141706.38039-22-cgoettsche@seltendoof.de (mailing list archive)
State New
Delegated to: Petr Lautrbach
Headers show
Series [01/47] libsemanage: white space cleanup | expand

Commit Message

Christian Göttsche Nov. 11, 2024, 2:16 p.m. UTC
From: Christian Göttsche <cgzones@googlemail.com>

Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
---
 libsemanage/src/ibendports_local.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/libsemanage/src/ibendports_local.c b/libsemanage/src/ibendports_local.c
index e696fdca..feebfa63 100644
--- a/libsemanage/src/ibendports_local.c
+++ b/libsemanage/src/ibendports_local.c
@@ -80,8 +80,8 @@  int semanage_ibendport_validate_local(semanage_handle_t *handle)
 	semanage_ibendport_t **ibendports = NULL;
 	unsigned int nibendports = 0;
 	unsigned int i = 0, j = 0;
-	char *ibdev_name;
-	char *ibdev_name2;
+	char *ibdev_name = NULL;
+	char *ibdev_name2 = NULL;
 	int port;
 	int port2;
 
@@ -97,6 +97,8 @@  int semanage_ibendport_validate_local(semanage_handle_t *handle)
 	while (i < nibendports) {
 		int stop = 0;
 
+		free(ibdev_name);
+		ibdev_name = NULL;
 		if (STATUS_SUCCESS !=
 				semanage_ibendport_get_ibdev_name(handle,
 								  ibendports[i],
@@ -114,6 +116,8 @@  int semanage_ibendport_validate_local(semanage_handle_t *handle)
 			if (j == nibendports - 1)
 				goto next;
 			j++;
+			free(ibdev_name2);
+			ibdev_name2 = NULL;
 			if (STATUS_SUCCESS !=
 				semanage_ibendport_get_ibdev_name(handle,
 								  ibendports[j],
@@ -136,6 +140,8 @@  next:
 		j = i;
 	}
 
+	free(ibdev_name);
+	free(ibdev_name2);
 	for (i = 0; i < nibendports; i++)
 		semanage_ibendport_free(ibendports[i]);
 	free(ibendports);
@@ -145,6 +151,8 @@  err:
 	ERR(handle, "could not complete ibendports validity check");
 
 invalid:
+	free(ibdev_name);
+	free(ibdev_name2);
 	for (i = 0; i < nibendports; i++)
 		semanage_ibendport_free(ibendports[i]);
 	free(ibendports);