fixed a trie (corruption/invalid memory access) bug found while investigating amb779
fixed a trie (corruption/invalid memory access) bug found while investigating
amb779
1.1 --- a/core/sm_trie.cpp Sun Aug 19 18:34:36 2007 +0000
1.2 +++ b/core/sm_trie.cpp Tue Aug 21 16:20:28 2007 +0000
1.3 @@ -558,7 +558,12 @@
1.4 if (base[newidx].mode == Node_Arc)
1.5 {
1.6 TrieNode *check_base = &base[base[newidx].idx] + 1;
1.7 - for (unsigned int j=1; j<=255; j++, check_base++)
1.8 + outgoing_limit = (base + trie->baseSize + 1) - check_base;
1.9 + if (outgoing_limit > 255)
1.10 + {
1.11 + outgoing_limit = 255;
1.12 + }
1.13 + for (unsigned int j=1; j<=outgoing_limit; j++, check_base++)
1.14 {
1.15 if (check_base->parent == oldidx)
1.16 {
1.17 @@ -602,7 +607,12 @@
1.18 if (base[newidx].mode == Node_Arc)
1.19 {
1.20 TrieNode *check_base = &base[base[newidx].idx] + 1;
1.21 - for (unsigned int j=1; j<=255; j++, check_base++)
1.22 + outgoing_limit = (base + trie->baseSize + 1) - check_base;
1.23 + if (outgoing_limit > 255)
1.24 + {
1.25 + outgoing_limit = 255;
1.26 + }
1.27 + for (unsigned int j=1; j<=outgoing_limit; j++, check_base++)
1.28 {
1.29 if (check_base->parent == oldidx)
1.30 {