Blame SOURCES/0077-libmultipath-don-t-leak-memory-on-invalid-strings.patch

86e138
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
86e138
From: Benjamin Marzinski <bmarzins@redhat.com>
86e138
Date: Wed, 14 Dec 2022 15:38:19 -0600
86e138
Subject: [PATCH] libmultipath: don't leak memory on invalid strings
86e138
86e138
If set_path() or set_str_noslash() are called with a bad value, they
86e138
ignore it and continue to use the old value. But they weren't freeing
86e138
the bad value, causing a memory leak.
86e138
86e138
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
86e138
Reviewed-by: Martin Wilck <mwilck@suse.com>
86e138
---
86e138
 libmultipath/dict.c | 2 ++
86e138
 1 file changed, 2 insertions(+)
86e138
86e138
diff --git a/libmultipath/dict.c b/libmultipath/dict.c
86e138
index 46b9f225..861d1d17 100644
86e138
--- a/libmultipath/dict.c
86e138
+++ b/libmultipath/dict.c
86e138
@@ -156,6 +156,7 @@ set_path(vector strvec, void *ptr, const char *file, int line_nr)
86e138
 	if ((*str_ptr)[0] != '/'){
86e138
 		condlog(1, "%s line %d, %s is not an absolute path. Ignoring",
86e138
 			file, line_nr, *str_ptr);
86e138
+		free(*str_ptr);
86e138
 		*str_ptr = old_str;
86e138
 	} else
86e138
 		free(old_str);
86e138
@@ -176,6 +177,7 @@ set_str_noslash(vector strvec, void *ptr, const char *file, int line_nr)
86e138
 	if (strchr(*str_ptr, '/')) {
86e138
 		condlog(1, "%s line %d, %s cannot contain a slash. Ignoring",
86e138
 			file, line_nr, *str_ptr);
86e138
+		free(*str_ptr);
86e138
 		*str_ptr = old_str;
86e138
 	} else
86e138
 		free(old_str);