Browse code

Break early if strlen(neddle) > strlen(haystack)

This should never happen if this is called properly (match only returns
valid results if there IS a match), but it's nice to double check here.

John Hawthorn authored on 28/12/2019 01:54:34
Showing 1 changed files

... ...
@@ -76,7 +76,7 @@ score_t match_positions(const char *needle, const char *haystack, size_t *positi
76 76
 	int n = strlen(needle);
77 77
 	int m = strlen(haystack);
78 78
 
79
-	if (m > MATCH_MAX_LEN || n > MATCH_MAX_LEN) {
79
+	if (m > MATCH_MAX_LEN || n > m) {
80 80
 		/*
81 81
 		 * Unreasonably large candidate: return no score
82 82
 		 * If it is a valid match it will still be returned, it will