| ... | ... |
@@ -7,6 +7,8 @@ typedef double score_t; |
| 7 | 7 |
#define SCORE_MAX INFINITY |
| 8 | 8 |
#define SCORE_MIN -INFINITY |
| 9 | 9 |
|
| 10 |
+#define MATCH_MAX_LEN 1024 |
|
| 11 |
+ |
|
| 10 | 12 |
int has_match(const char *needle, const char *haystack); |
| 11 | 13 |
score_t match_positions(const char *needle, const char *haystack, size_t *positions); |
| 12 | 14 |
score_t match(const char *needle, const char *haystack); |
| ... | ... |
@@ -36,8 +36,8 @@ static void draw_match(tty_interface_t *state, const char *choice, int selected) |
| 36 | 36 |
char *search = state->last_search; |
| 37 | 37 |
|
| 38 | 38 |
int n = strlen(search); |
| 39 |
- size_t positions[n + 1]; |
|
| 40 |
- for (int i = 0; i < n + 1; i++) |
|
| 39 |
+ size_t positions[MATCH_MAX_LEN]; |
|
| 40 |
+ for (int i = 0; i < n + 1 && i < MATCH_MAX_LEN; i++) |
|
| 41 | 41 |
positions[i] = -1; |
| 42 | 42 |
|
| 43 | 43 |
score_t score = match_positions(search, choice, &positions[0]); |