From 77d3a20d7fba0f5642b2e73222a4cca34de5e8ef Mon Sep 17 00:00:00 2001 From: John Hawthorn Date: Fri, 27 Dec 2019 17:54:34 -0800 Subject: 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. --- src/match.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/match.c b/src/match.c index c028b87..38b26e1 100644 --- a/src/match.c +++ b/src/match.c @@ -76,7 +76,7 @@ score_t match_positions(const char *needle, const char *haystack, size_t *positi int n = strlen(needle); int m = strlen(haystack); - if (m > MATCH_MAX_LEN || n > MATCH_MAX_LEN) { + if (m > MATCH_MAX_LEN || n > m) { /* * Unreasonably large candidate: return no score * If it is a valid match it will still be returned, it will -- cgit v1.2.3