Skip to contentSkip to conversation

util/parse-configs: Fix a resource leak in search_section_kv()

PATCH In review Vishal Verma 2 participants 2 messages Dec 18, 2021 libnvdimm: non-volatile memory device

lore
Share & tools
lore

Vishal Verma

author maintainer
#0 lore raw

PATCH 1/1 util/parse-configs: Fix a resource leak in search_section_kv()

Static analysis points out that the memory pointed to by 'cur_sec' may be leaked. Fix the missed goto error; vs return NULL; exit path for an error condition here.

---
 util/parse-configs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
util/parse-configs.c +1 -1
index 49ee4e0..1b7ffa6 100644
@@ -57,7 +57,7 @@ static const char *search_section_kv(dictionary *d, const struct config *c)
 			return NULL;
 		if (!c->section || !c->search_key || !c->search_val || !c->get_key) {
 			fprintf(stderr, "warning: malformed config query, skipping\n");
-			return NULL;
+			goto out_sec;
 		}
 
 		cur = strtok_r(cur_sec, delim, &save);

base-commit: c55b18181281b2fffadb9e0e8955d74b8b719349

Signature · 1 line
2.33.1