diff mbox series

[12/16] libmultipath: cleanup_free_ptr(): avoid double free

Message ID 20220901160952.2167-13-mwilck@suse.com (mailing list archive)
State Not Applicable, archived
Delegated to: christophe varoqui
Headers show
Series multipath-tools: minor fixes and build improvements | expand

Commit Message

Martin Wilck Sept. 1, 2022, 4:09 p.m. UTC
From: Martin Wilck <mwilck@suse.com>

... by nullifying the passed pointer after freeing it.

Signed-off-by: Martin Wilck <mwilck@suse.com>
---
 libmpathutil/util.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/libmpathutil/util.c b/libmpathutil/util.c
index 1539738..6692ac2 100644
--- a/libmpathutil/util.c
+++ b/libmpathutil/util.c
@@ -391,8 +391,10 @@  void cleanup_free_ptr(void *arg)
 {
 	void **p = arg;
 
-	if (p && *p)
+	if (p && *p) {
 		free(*p);
+		*p = NULL;
+	}
 }
 
 void cleanup_fd_ptr(void *arg)