solve invalid read
This commit is contained in:
@@ -199,6 +199,7 @@ void maat_compile_free(struct maat_compile *compile)
|
||||
struct maat_clause_state *clause_state = NULL;
|
||||
if (compile->user_data && compile->user_data_free) {
|
||||
compile->user_data_free(compile->user_data);
|
||||
compile->user_data = NULL;
|
||||
}
|
||||
|
||||
for (int i = 0; i < MAX_ITEMS_PER_BOOL_EXPR; i++) {
|
||||
|
||||
@@ -433,11 +433,6 @@ int load_maat_json_file(struct maat *maat_instance, const char *json_filename,
|
||||
if (ret < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!maat_instance->is_running) {
|
||||
size_t len = MIN(strlen(json_filename), sizeof(maat_instance->json_ctx.json_file));
|
||||
strncpy(maat_instance->json_ctx.json_file, json_filename, len);
|
||||
}
|
||||
|
||||
ret = stat(json_filename, &fstat_buf);
|
||||
maat_instance->json_ctx.last_md5_time = fstat_buf.st_ctim;
|
||||
|
||||
@@ -70,6 +70,7 @@ void ex_data_runtime_free(struct ex_data_runtime *ex_data_rt)
|
||||
|
||||
if (ex_data_rt->htable != NULL) {
|
||||
rcu_hash_free(ex_data_rt->htable);
|
||||
ex_data_rt->htable = NULL;
|
||||
}
|
||||
|
||||
FREE(ex_data_rt);
|
||||
@@ -172,6 +173,7 @@ void ex_container_free(void *user_ctx, void *data)
|
||||
/* free ex_container->custom_data */
|
||||
if (container->custom_data != NULL && container_schema->custom_data_free != NULL) {
|
||||
container_schema->custom_data_free(container->custom_data);
|
||||
container->custom_data = NULL;
|
||||
}
|
||||
|
||||
/* free ex_container->ex_data */
|
||||
@@ -179,6 +181,7 @@ void ex_container_free(void *user_ctx, void *data)
|
||||
container_schema->ex_schema.free_func(container_schema->table_id, &(container->ex_data),
|
||||
container_schema->ex_schema.argl,
|
||||
container_schema->ex_schema.argp);
|
||||
container->ex_data = NULL;
|
||||
}
|
||||
|
||||
FREE(container);
|
||||
|
||||
@@ -1071,7 +1071,7 @@ void expr_runtime_perf_stat(struct expr_runtime *expr_rt, size_t scan_len,
|
||||
expr_rt->scan_cpu_time = alignment_int64_array_alloc(expr_rt->n_worker_thread);
|
||||
}
|
||||
|
||||
long long consume_time = (end->tv_sec - start->tv_sec) * 1000000000 + end->tv_nsec - start->tv_nsec;
|
||||
long long consume_time = (end->tv_sec - start->tv_sec) * 1000000000 + (end->tv_nsec - start->tv_nsec);
|
||||
alignment_int64_array_add(expr_rt->scan_cpu_time, thread_id, consume_time);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,8 +32,8 @@
|
||||
|
||||
#define MODULE_MAAT_RULE module_name_str("maat.rule")
|
||||
|
||||
struct maat_item *maat_item_new(long long item_id, long long group_id, void *user_data,
|
||||
void (*user_data_free)(void *))
|
||||
struct maat_item *maat_item_new(long long item_id, long long group_id,
|
||||
void *user_data, void (*user_data_free)(void *))
|
||||
{
|
||||
struct maat_item *item = NULL;
|
||||
item = ALLOC(struct maat_item, 1);
|
||||
@@ -53,7 +53,7 @@ void maat_item_free(void *maat_item)
|
||||
item->user_data = NULL;
|
||||
}
|
||||
|
||||
free(item);
|
||||
FREE(item);
|
||||
}
|
||||
|
||||
static int compare_each_tag(cJSON *tag_obj, const struct rule_tag *accept_tags, size_t n_accept_tag)
|
||||
|
||||
@@ -31,8 +31,7 @@ enum MAAT_FS_STATUS {
|
||||
STATUS_GROUP_REF_NUM,
|
||||
STATUS_GROUP_REF_NOT_NUM,
|
||||
STATUS_COMPILE_RULE_NUM,
|
||||
STATUS_OUTER_MID_NUM,
|
||||
STATUS_INNER_MID_NUM,
|
||||
STATUS_MAAT_STATE_NUM,
|
||||
STATUS_GARBAGE_QSIZE,
|
||||
STATUS_TOTAL_SCAN_LEN,
|
||||
STATUS_TOTAL_SCAN_CNT,
|
||||
@@ -90,8 +89,8 @@ void maat_fieldstat_register(struct maat_stat *stat)
|
||||
"compile", NULL, 0);
|
||||
stat->fs_status_id[STATUS_GARBAGE_QSIZE] = fieldstat_register(stat->fs_handle, FIELD_TYPE_GAUGE,
|
||||
"garbage_num", NULL, 0);
|
||||
stat->fs_status_id[STATUS_OUTER_MID_NUM] = fieldstat_register(stat->fs_handle, FIELD_TYPE_GAUGE,
|
||||
"outer_mid", NULL, 0);
|
||||
stat->fs_status_id[STATUS_MAAT_STATE_NUM] = fieldstat_register(stat->fs_handle, FIELD_TYPE_GAUGE,
|
||||
"maat_state", NULL, 0);
|
||||
stat->fs_status_id[STATUS_ZOMBIE_RS_STREAM] = fieldstat_register(stat->fs_handle, FIELD_TYPE_GAUGE,
|
||||
"z_stream", NULL, 0);
|
||||
stat->fs_status_id[STATUS_NOT_GROUP_HIT] = fieldstat_register(stat->fs_handle, FIELD_TYPE_GAUGE,
|
||||
|
||||
@@ -471,11 +471,6 @@ void maat_table_free(struct maat_table *maat_tbl)
|
||||
return;
|
||||
}
|
||||
|
||||
if (maat_tbl->schema != NULL) {
|
||||
maat_table_schema_free(maat_tbl->schema, maat_tbl->table_type);
|
||||
maat_tbl->schema = NULL;
|
||||
}
|
||||
|
||||
if (maat_tbl->runtime != NULL) {
|
||||
maat_table_runtime_free(maat_tbl->runtime, maat_tbl->table_type);
|
||||
maat_tbl->runtime = NULL;
|
||||
@@ -486,6 +481,11 @@ void maat_table_free(struct maat_table *maat_tbl)
|
||||
maat_tbl->updating_runtime = NULL;
|
||||
}
|
||||
|
||||
if (maat_tbl->schema != NULL) {
|
||||
maat_table_schema_free(maat_tbl->schema, maat_tbl->table_type);
|
||||
maat_tbl->schema = NULL;
|
||||
}
|
||||
|
||||
FREE(maat_tbl);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user