增加对group_num为0的编译配置的处理。

This commit is contained in:
zhengchao
2020-07-31 19:30:16 +08:00
parent 9eac53c0ab
commit 5931b445ff
2 changed files with 10 additions and 3 deletions

View File

@@ -331,7 +331,7 @@ int Maat_hierarchy_compile_add(struct Maat_hierarchy* hier, int compile_id, int
HASH_FIND_INT(hier->hash_compile_by_id, &compile_id, compile); HASH_FIND_INT(hier->hash_compile_by_id, &compile_id, compile);
if(!compile) if(!compile)
{ {
assert(declared_clause_num>0); assert(declared_clause_num>=0);
compile=Maat_hierarchy_compile_new(hier, compile_id); compile=Maat_hierarchy_compile_new(hier, compile_id);
compile->declared_clause_num=declared_clause_num; compile->declared_clause_num=declared_clause_num;
compile->user_data=user_data; compile->user_data=user_data;
@@ -791,7 +791,8 @@ static struct bool_matcher* Maat_hierarchy_build_bool_matcher(struct Maat_hierar
j++; j++;
} }
} }
if(j==compile->declared_clause_num) //some compile may have zero groups, e.g. default policy.
if(j==compile->declared_clause_num&&j>0)
{ {
bool_expr_array[expr_cnt].user_tag=compile; bool_expr_array[expr_cnt].user_tag=compile;
bool_expr_array[expr_cnt].item_num=j; bool_expr_array[expr_cnt].item_num=j;
@@ -802,6 +803,12 @@ static struct bool_matcher* Maat_hierarchy_build_bool_matcher(struct Maat_hierar
//Final STEP, build the bool matcher. //Final STEP, build the bool matcher.
size_t mem_size=0; size_t mem_size=0;
if(expr_cnt==0)
{
MESA_handle_runtime_log(hier->logger, RLOG_LV_FATAL, module_maat_hierarchy,
"No expr to build.");
return NULL;
}
bm=bool_matcher_new(bool_expr_array, expr_cnt, hier->thread_num, &mem_size); bm=bool_matcher_new(bool_expr_array, expr_cnt, hier->thread_num, &mem_size);
if(bm!=NULL) if(bm!=NULL)
{ {

View File

@@ -34,7 +34,7 @@
#include "stream_fuzzy_hash.h" #include "stream_fuzzy_hash.h"
#include "gram_index_engine.h" #include "gram_index_engine.h"
int MAAT_FRAME_VERSION_3_0_20200724=1; int MAAT_FRAME_VERSION_3_0_20200731=1;
int is_valid_table_name(const char* str) int is_valid_table_name(const char* str)
{ {