From: yu.dongliang <18588496441@163.com> Date: Fri, 10 Feb 2023 04:01:59 +0000 (+0800) Subject: fix issue #I6E6LZ: scf crash when analysize multi-return-values function. X-Git-Url: http://baseworks.info/?a=commitdiff_plain;h=57ef0277e7094984900eda3ba33bc31c4ae94ee0;p=scf.git fix issue #I6E6LZ: scf crash when analysize multi-return-values function. --- diff --git a/core/scf_dag.c b/core/scf_dag.c index 0c6cbdb..7e7b44d 100644 --- a/core/scf_dag.c +++ b/core/scf_dag.c @@ -319,7 +319,7 @@ scf_dag_node_t* scf_dag_node_alloc(int type, scf_variable_t* var, const scf_node if (SCF_OP_CALL == type) { scf_logw("dag_node: %#lx, dag_node->type: %d", 0xffff & (uintptr_t)dag_node, dag_node->type); if (var) { - printf(", var: %p, var->type: %d", var, var->type); + printf(", var: %#lx, var->type: %d", 0xffff & (uintptr_t)var, var->type); if (var->w) printf(", v_%d_%d/%s", var->w->line, var->w->pos, var->w->text->data); else { @@ -496,11 +496,19 @@ int scf_dag_node_same(scf_dag_node_t* dag_node, const scf_node_t* node) { int i; + const scf_node_t* split = NULL; + if (node->split_flag) { if (dag_node->var != _scf_operand_get(node)) return 0; - node = node->split_parent; + + split = node; + node = node->split_parent; + + scf_logd("split type: %d, node: %#lx, var: %#lx\n", split->type, 0xffff & (uintptr_t)split, 0xffff & (uintptr_t)split->var); + scf_logd("node type: %d, node: %#lx, var: %#lx\n", node->type, 0xffff & (uintptr_t)node, 0xffff & (uintptr_t)node->var); + scf_logd("dag type: %d, node: %#lx, var: %#lx\n", dag_node->type, 0xffff & (uintptr_t)dag_node, 0xffff & (uintptr_t)dag_node->var); } if (dag_node->type != node->type) @@ -636,6 +644,9 @@ cmp_childs: scf_variable_t* v0 = _scf_operand_get(node); scf_variable_t* v1 = dag_node->var; + if (split) + v0 = _scf_operand_get(split); + if (v0 && v0->w && v1 && v1->w) { if (v0->type != v1->type) { scf_loge("v0: %d/%s_%#lx, split_flag: %d\n", v0->w->line, v0->w->text->data, 0xffff & (uintptr_t)v0, node->split_flag); diff --git a/parse/scf_dfa_container.c b/parse/scf_dfa_container.c index cc791e6..cc8d6c7 100644 --- a/parse/scf_dfa_container.c +++ b/parse/scf_dfa_container.c @@ -83,6 +83,9 @@ static int _container_action_comma(scf_dfa_t* dfa, scf_vector_t* words, void* da scf_stack_t* s = d->module_datas[dfa_module_container.index]; dfa_container_data_t* cd = scf_stack_top(s); + if (!cd) + return SCF_DFA_NEXT_SYNTAX; + if (0 == cd->container->nb_nodes) { if (!d->expr) { scf_loge("\n"); diff --git a/parse/scf_dfa_type.c b/parse/scf_dfa_type.c index 62e5f4c..ba4804d 100644 --- a/parse/scf_dfa_type.c +++ b/parse/scf_dfa_type.c @@ -309,7 +309,7 @@ static int _dfa_init_syntax_type(scf_dfa_t* dfa) for (i = 0; i < base_type->childs->size; i++) { scf_dfa_node_t* n = base_type->childs->data[i]; - scf_logi("n->name: %s\n", n->name); + scf_logw("n->name: %s\n", n->name); } scf_logi("\n");