fix utarray_free null bug

This commit is contained in:
liuwentan
2023-05-08 18:51:53 +08:00
parent f7bde76fcf
commit 4540321998
4 changed files with 49 additions and 29 deletions

View File

@@ -666,8 +666,10 @@ void adapter_hs_stream_close(struct adapter_hs_stream *hs_stream)
same as hs_attr */
hs_stream->ref_hs_rt = NULL;
hs_stream->matched_pat->ref_hs_attr = NULL;
utarray_free(hs_stream->matched_pat->pattern_ids);
hs_stream->matched_pat->pattern_ids = NULL;
if (hs_stream->matched_pat->pattern_ids != NULL) {
utarray_free(hs_stream->matched_pat->pattern_ids);
hs_stream->matched_pat->pattern_ids = NULL;
}
FREE(hs_stream->matched_pat);
FREE(hs_stream);

View File

@@ -592,8 +592,12 @@ void literal2clause_hash_free(struct literal_clause *hash)
HASH_ITER(hh, hash, l2c_val, tmp_l2c_val) {
HASH_DEL(hash, l2c_val);
utarray_free(l2c_val->clause_ids);
free(l2c_val);
if (l2c_val->clause_ids != NULL) {
utarray_free(l2c_val->clause_ids);
l2c_val->clause_ids = NULL;
}
FREE(l2c_val);
}
assert(hash == NULL);
}
@@ -1414,9 +1418,21 @@ void maat_compile_state_free(struct maat_compile_state *compile_state)
return;
}
utarray_free(compile_state->internal_hit_paths);
utarray_free(compile_state->all_hit_clauses);
utarray_free(compile_state->this_scan_hit_clauses);
if (compile_state->internal_hit_paths != NULL) {
utarray_free(compile_state->internal_hit_paths);
compile_state->internal_hit_paths = NULL;
}
if (compile_state->all_hit_clauses != NULL) {
utarray_free(compile_state->all_hit_clauses);
compile_state->all_hit_clauses = NULL;
}
if (compile_state->this_scan_hit_clauses != NULL) {
utarray_free(compile_state->this_scan_hit_clauses);
compile_state->this_scan_hit_clauses = NULL;
}
free(compile_state);
}

View File

@@ -126,8 +126,11 @@ void ex_data_runtime_clear_row_cache(struct ex_data_runtime *ex_data_rt)
return;
}
utarray_free(ex_data_rt->cache_rows);
ex_data_rt->cache_rows = NULL;
if (ex_data_rt->cache_rows != NULL) {
utarray_free(ex_data_rt->cache_rows);
ex_data_rt->cache_rows = NULL;
}
ex_data_rt->cache_row_num = 0;
ex_data_rt->cache_size = 0;
}

View File

@@ -153,15 +153,25 @@ void group2group_schema_free(void *g2g_schema)
void group_vertex_free(struct maat_group *group)
{
utarray_free(group->incl_super_group_ids);
utarray_free(group->excl_super_group_ids);
utarray_free(group->incl_sub_group_ids);
utarray_free(group->excl_sub_group_ids);
group->incl_super_group_ids = NULL;
group->excl_super_group_ids = NULL;
group->incl_sub_group_ids = NULL;
group->excl_sub_group_ids = NULL;
if (group->incl_super_group_ids != NULL) {
utarray_free(group->incl_super_group_ids);
group->incl_super_group_ids = NULL;
}
if (group->excl_super_group_ids != NULL) {
utarray_free(group->excl_super_group_ids);
group->excl_super_group_ids = NULL;
}
if (group->incl_sub_group_ids != NULL) {
utarray_free(group->incl_sub_group_ids);
group->incl_sub_group_ids = NULL;
}
if (group->excl_sub_group_ids != NULL) {
utarray_free(group->excl_sub_group_ids);
group->excl_sub_group_ids = NULL;
}
FREE(group);
}
@@ -648,16 +658,6 @@ int group_topology_build_super_groups(struct maat_group_topology *group_topo)
//Orphan, Not reference by any one, free it.
if (0 == group->ref_by_super_group_cnt
&& 0 == group->ref_by_sub_group_cnt) {
utarray_free(group->incl_super_group_ids);
utarray_free(group->excl_super_group_ids);
utarray_free(group->incl_sub_group_ids);
utarray_free(group->excl_sub_group_ids);
group->incl_super_group_ids = NULL;
group->excl_super_group_ids = NULL;
group->incl_sub_group_ids = NULL;
group->excl_sub_group_ids = NULL;
group_topology_del_group(group_topo, group);
continue;
}
@@ -877,7 +877,6 @@ void verify_candidate_super_group_ids(struct maat_group_topology *group_topo, UT
verify_candidate_super_group_ids(group_topo, kept_group_ids, all_hit_group_ids, depth);
next:
utarray_free(kept_group_ids);
kept_group_ids = NULL;
}
size_t group_topology_get_super_groups(struct maat_group_topology *group_topo,