ovsdb-idlc: Fix memory leak reported by Coverity.
Coverity shows the following memory leak in this code pattern:
void
ovsrec_ipfix_index_set_obs_domain_id(...
{
struct ovsdb_datum datum;
// 1. alloc_fn: Storage is returned from allocation function xmalloc.
// 2. var_assign: Assigning: key = storage returned from xmalloc(16UL).
union ovsdb_atom *key = xmalloc(sizeof(union ovsdb_atom));
// 3. Condition n_obs_domain_id, taking false branch.
if (n_obs_domain_id) {
datum.n = 1;
datum.keys = key;
key->integer = *obs_domain_id;
} else {
datum.n = 0;
datum.keys = NULL;
}
datum.values = NULL;
ovsdb_idl_index_write(CONST_CAST(struct ovsdb_idl_row *, &row->head...
// CID
1420891 (#1 of 1): Resource leak (RESOURCE_LEAK)
Fixed it by moving the xmalloc to the true branch.
Reviewed-by: Yifeng Sun <pkusunyifeng@gmail.com>
Signed-off-by: William Tu <u9012063@gmail.com>