Fix a leak found by clang where we were not cleaning up properly in
the error path.
CC libseccomp_la-db.lo
db.c:2020:2: warning: Potential leak of memory pointed to by 'rule_s'
_db_snap_release(snap);
^~~~~~~~~~~~~~~~
Signed-off-by: Paul Moore <paul@paul-moore.com>
unsigned int iter;
struct db_filter_snap *snap;
struct db_filter *filter_o, *filter_s;
- struct db_api_rule_list *rule_o, *rule_s, *rule_tmp;
+ struct db_api_rule_list *rule_o, *rule_s = NULL, *rule_tmp;
/* allocate the snapshot */
snap = zmalloc(sizeof(*snap));
rule_tmp->next = rule_s;
filter_s->rules = rule_s;
}
+ rule_s = NULL;
/* next rule */
rule_o = rule_o->next;
return 0;
trans_start_failure:
+ if (rule_s != NULL)
+ free(rule_s);
_db_snap_release(snap);
return -ENOMEM;
}