Message ID | 20211218035922.347380-1-vishal.l.verma@intel.com (mailing list archive) |
---|---|
State | Accepted |
Commit | 3d90ebfae265341cd398c963722f930d102864e8 |
Headers | show |
Series | [ndctl] util/parse-configs: Fix a resource leak in search_section_kv() | expand |
On Fri, Dec 17, 2021 at 7:59 PM Vishal Verma <vishal.l.verma@intel.com> wrote: > > 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. > > Cc: Dan Williams <dan.j.williams@intel.com> > Signed-off-by: Vishal Verma <vishal.l.verma@intel.com> Static analysis scores a point. Reviewed-by: Dan Williams <dan.j.williams@intel.com>
diff --git a/util/parse-configs.c b/util/parse-configs.c index 49ee4e0..1b7ffa6 100644 --- a/util/parse-configs.c +++ b/util/parse-configs.c @@ -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);
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. Cc: Dan Williams <dan.j.williams@intel.com> Signed-off-by: Vishal Verma <vishal.l.verma@intel.com> --- util/parse-configs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) base-commit: c55b18181281b2fffadb9e0e8955d74b8b719349