Skip to content
Browse files

Increase Bio.trie MAX_KEY_LENGTH and check if exceeded

  • Loading branch information...
1 parent c838119 commit 31909c8725d5cfbfba2096b7c15ef7afeaf20a5b Jeffrey Chang committed with peterjc Feb 1, 2013
Showing with 9 additions and 2 deletions.
  1. +9 −2 Bio/trie.c
View
11 Bio/trie.c
@@ -38,7 +38,7 @@ struct Trie {
};
-#define MAX_KEY_LENGTH 1000
+#define MAX_KEY_LENGTH (1024*1024)
static char KEY[MAX_KEY_LENGTH];
@@ -723,6 +723,10 @@ int _deserialize_trie(Trie* trie,
malloc(trie->num_transitions*sizeof(Transition))))
goto _deserialize_trie_error;
for(i=0; i<trie->num_transitions; i++) {
+ trie->transitions[i].suffix = NULL;
+ trie->transitions[i].next = NULL;
+ }
+ for(i=0; i<trie->num_transitions; i++) {
if(!_deserialize_transition(&trie->transitions[i],
read, read_value, data))
goto _deserialize_trie_error;
@@ -751,8 +755,11 @@ int _deserialize_transition(Transition* transition,
if(!(*read)(&suffixlen, sizeof(suffixlen), data))
goto _deserialize_transition_error;
- if(suffixlen < 0 || suffixlen >= MAX_KEY_LENGTH)
+ if(suffixlen < 0 || suffixlen >= MAX_KEY_LENGTH) {
+ printf("MAX_KEY_LENGTH too short [%d:%d]\n",
+ MAX_KEY_LENGTH, suffixlen);
goto _deserialize_transition_error;
+ }
if(!(*read)(KEY, suffixlen, data))
goto _deserialize_transition_error;
KEY[suffixlen] = 0;

0 comments on commit 31909c8

Please sign in to comment.
Something went wrong with that request. Please try again.