diff options
author | John Hawthorn <john@hawthorn.email> | 2019-12-27 17:54:34 -0800 |
---|---|---|
committer | John Hawthorn <john@hawthorn.email> | 2019-12-27 18:44:55 -0800 |
commit | 77d3a20d7fba0f5642b2e73222a4cca34de5e8ef (patch) | |
tree | eff094c63f306b8f0c44dfd864e17eafbca1e51b | |
parent | 2afbce950e820f6d1f479f5809149390a59db76a (diff) |
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.
-rw-r--r-- | src/match.c | 2 |
1 files changed, 1 insertions, 1 deletions
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 |