diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2008-05-09 18:39:37 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2008-05-09 18:39:37 +0000 |
commit | 8888d8ef07529fcff1913a89be7dea72d731530b (patch) | |
tree | 0d5c92fbaa9fb82b727aa3acfc329fd78d5a654c /src/wildcard.cpp | |
parent | 03ef675c0dd4742464d8ad93888e98721a044108 (diff) |
Add test suites for edge cases and in the process, spot a crash in the new code and fix it (empty mask in the match() functions makes it bomb)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@9682 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/wildcard.cpp')
-rw-r--r-- | src/wildcard.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/wildcard.cpp b/src/wildcard.cpp index 9846b7d4f..3a91e8350 100644 --- a/src/wildcard.cpp +++ b/src/wildcard.cpp @@ -35,6 +35,9 @@ CoreExport bool csmatch(const std::string &str, const std::string &mask) std::string::const_iterator wild = mask.begin(); std::string::const_iterator string = str.begin(); + if (mask.empty()) + return false; + while ((string != str.end()) && (wild != mask.end()) && (*wild != '*')) { if ((*wild != *string) && (*wild != '?')) @@ -81,6 +84,9 @@ CoreExport bool match(const std::string &str, const std::string &mask) std::string::const_iterator wild = mask.begin(); std::string::const_iterator string = str.begin(); + if (mask.empty()) + return false; + while ((string != str.end()) && (wild != mask.end()) && (*wild != '*')) { if ((lowermap[(unsigned char)*wild] != lowermap[(unsigned char)*string]) && (*wild != '?')) |