bb#9659 correction to construction of Aho-Corasick trie fail links.

This commit is contained in:
Steven Morgan 2014-01-02 17:19:05 -05:00
parent 9354e51399
commit 51c9a991eb

View file

@ -315,9 +315,10 @@ static int ac_maketrans(struct cli_matcher *root)
while((node = bfs_dequeue(&bfs, &bfs_last))) { while((node = bfs_dequeue(&bfs, &bfs_last))) {
if(IS_LEAF(node)) { if(IS_LEAF(node)) {
struct cli_ac_node *failtarget = node->fail; struct cli_ac_node *failtarget = node->fail;
while(IS_LEAF(failtarget)) while (NULL != failtarget && (IS_LEAF(failtarget) || !IS_FINAL(failtarget)))
failtarget = failtarget->fail; failtarget = failtarget->fail;
node->fail = failtarget; if (NULL != failtarget)
node->fail = failtarget;
continue; continue;
} }