[BUGFIX]fix maat_compile_state_free null pointer
This commit is contained in:
@@ -388,6 +388,7 @@ void maat_free(struct maat *maat_instance)
|
||||
while (0 == maat_instance->is_running) {
|
||||
usleep(500 * 1000);
|
||||
}
|
||||
|
||||
maat_instance->is_running = 0;
|
||||
pthread_join(maat_instance->cfg_mon_thread, &ret);
|
||||
}
|
||||
@@ -443,6 +444,14 @@ int maat_table_callback_register(struct maat *maat_instance, int table_id,
|
||||
|
||||
pthread_mutex_lock(&(maat_instance->background_update_mutex));
|
||||
void *schema = table_manager_get_schema(maat_instance->tbl_mgr, table_id);
|
||||
if (NULL == schema) {
|
||||
pthread_mutex_unlock(&(maat_instance->background_update_mutex));
|
||||
log_error(maat_instance->logger, MODULE_MAAT_API,
|
||||
"[%s:%d] table(table_id:%d) schema is NULL, register callback failed",
|
||||
__FUNCTION__, __LINE__, table_id);
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = plugin_table_add_callback(schema, table_id, start, update, finish,
|
||||
u_para, maat_instance->logger);
|
||||
if (ret < 0) {
|
||||
@@ -456,10 +465,16 @@ int maat_table_callback_register(struct maat *maat_instance, int table_id,
|
||||
}
|
||||
|
||||
void *runtime = table_manager_get_runtime(maat_instance->tbl_mgr, table_id);
|
||||
enum table_type table_type = table_manager_get_table_type(maat_instance->tbl_mgr, table_id);
|
||||
assert(table_type == TABLE_TYPE_PLUGIN);
|
||||
size_t row_cnt = plugin_runtime_cached_row_count(runtime);
|
||||
|
||||
enum table_type table_type = table_manager_get_table_type(maat_instance->tbl_mgr, table_id);
|
||||
if (table_type != TABLE_TYPE_PLUGIN) {
|
||||
pthread_mutex_unlock(&(maat_instance->background_update_mutex));
|
||||
log_error(maat_instance->logger, MODULE_MAAT_API,
|
||||
"[%s:%d] table type:%d illegal", __FUNCTION__, __LINE__, table_type);
|
||||
return -1;
|
||||
}
|
||||
|
||||
size_t row_cnt = plugin_runtime_cached_row_count(runtime);
|
||||
if (row_cnt > 0) {
|
||||
if (start != NULL) {
|
||||
start(MAAT_UPDATE_TYPE_FULL, u_para);
|
||||
@@ -1679,11 +1694,13 @@ void maat_state_free(struct maat_state *state)
|
||||
return;
|
||||
}
|
||||
|
||||
assert(state->compile_state != NULL);
|
||||
maat_compile_state_free(state->compile_state);
|
||||
state->compile_state = NULL;
|
||||
if (state->compile_state != NULL) {
|
||||
maat_compile_state_free(state->compile_state);
|
||||
state->compile_state = NULL;
|
||||
}
|
||||
|
||||
state->maat_instance = NULL;
|
||||
free(state);
|
||||
FREE(state);
|
||||
}
|
||||
|
||||
int maat_state_set_scan_district(struct maat_state *state, int vtable_id,
|
||||
|
||||
@@ -1414,7 +1414,6 @@ int maat_remove_group_from_compile(struct rcu_hash_table *hash_tbl,
|
||||
|
||||
if (0 == copy_compile->actual_clause_num && NULL == copy_compile->user_data) {
|
||||
maat_compile_free(copy_compile);
|
||||
copy_compile = NULL;
|
||||
} else {
|
||||
rcu_hash_add(hash_tbl, (char *)&compile_id, sizeof(long long), copy_compile);
|
||||
}
|
||||
@@ -1706,7 +1705,6 @@ int compile_runtime_add_compile(struct compile_runtime *compile_rt, struct compi
|
||||
|
||||
struct compile_rule *compile_rule = compile_rule_new(compile_item, schema, table_name, line);
|
||||
compile_item_free(compile_item);
|
||||
compile_item = NULL;
|
||||
|
||||
int updating_flag = rcu_hash_is_updating(compile_rt->cfg_hash_tbl);
|
||||
if (1 == updating_flag) {
|
||||
@@ -1756,7 +1754,7 @@ int compile_runtime_add_compile(struct compile_runtime *compile_rt, struct compi
|
||||
/* add copy_compile to rcu hash */
|
||||
rcu_hash_add(compile_rt->cfg_hash_tbl, (char *)&compile_id, sizeof(long long), copy_compile);
|
||||
} else {
|
||||
compile = maat_compile_new(compile_rule->compile_id);
|
||||
compile = maat_compile_new(compile_rule->compile_id);
|
||||
assert(compile != NULL);
|
||||
maat_compile_set(compile, table_name, compile_rule->declared_clause_num,
|
||||
compile_rule, (void (*)(void *))compile_rule_free);
|
||||
@@ -1815,7 +1813,6 @@ void compile_runtime_del_compile(struct compile_runtime *compile_rt, long long c
|
||||
|
||||
if (0 == copy_compile->actual_clause_num) {
|
||||
maat_compile_free(copy_compile);
|
||||
copy_compile = NULL;
|
||||
} else {
|
||||
rcu_hash_add(compile_rt->cfg_hash_tbl, (char *)&compile_id,
|
||||
sizeof(long long), copy_compile);
|
||||
|
||||
@@ -168,7 +168,7 @@ void fqdn_rule_free(struct FQDN_rule *fqdn_rule)
|
||||
FREE(fqdn_rule->FQDN);
|
||||
}
|
||||
|
||||
free(fqdn_rule);
|
||||
FREE(fqdn_rule);
|
||||
}
|
||||
|
||||
void *fqdn_plugin_runtime_new(void *fqdn_plugin_schema, size_t max_thread_num,
|
||||
|
||||
Reference in New Issue
Block a user