diff options
author | antirez <antirez@gmail.com> | 2020-05-06 16:18:21 +0200 |
---|---|---|
committer | antirez <antirez@gmail.com> | 2020-05-06 16:18:21 +0200 |
commit | e17f9311c8ee18996e4b932a1284e4cfe29c05b4 (patch) | |
tree | c03bb4299a1393d083929ccdf02cfdc9266955cc | |
parent | 2e2f57e23b69e87e7ac066d4de03b3a84ec6366f (diff) | |
download | redis-e17f9311c8ee18996e4b932a1284e4cfe29c05b4.tar.gz |
stringmatchlen() should not expect null terminated strings.
-rw-r--r-- | src/util.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/util.c b/src/util.c index 537c9313c..0d48f5701 100644 --- a/src/util.c +++ b/src/util.c @@ -51,7 +51,7 @@ int stringmatchlen(const char *pattern, int patternLen, while(patternLen && stringLen) { switch(pattern[0]) { case '*': - while (pattern[1] == '*') { + while (patternLen && pattern[1] == '*') { pattern++; patternLen--; } @@ -94,7 +94,7 @@ int stringmatchlen(const char *pattern, int patternLen, pattern--; patternLen++; break; - } else if (pattern[1] == '-' && patternLen >= 3) { + } else if (patternLen >= 3 && pattern[1] == '-') { int start = pattern[0]; int end = pattern[2]; int c = string[0]; |