In update_fields() p isn't freed is store_str fails. Since p is to be freed whatever the result of store_str() might be, move the call to free() before checking field_name. Fixes a RESSOURCE_LEAK error (CWE-772) Signed-off-by: Jerome Marchand <jmarchan@xxxxxxxxxx> --- src/tracefs-sqlhist.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tracefs-sqlhist.c b/src/tracefs-sqlhist.c index ecf09ce..c7b9eff 100644 --- a/src/tracefs-sqlhist.c +++ b/src/tracefs-sqlhist.c @@ -810,9 +810,9 @@ static int update_fields(struct tep_handle *tep, if (!p) return -1; field_name = store_str(sb, p); + free((char *)p); if (!field_name) return -1; - free((char *)p); } tfield = tep_find_any_field(event, field_name); -- 2.44.0