Skip to content

Commit

Permalink
Fixed bug in GitWildcardMatch
Browse files Browse the repository at this point in the history
  • Loading branch information
mxmauro committed Jul 31, 2022
1 parent 7e84d05 commit 8fd14fc
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions Miscellaneous.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ BOOL GitWildcardMatch(_In_ LPCWSTR szTextW, _In_ SIZE_T nTextLen, _In_ LPCWSTR s
{
if (nPatternOfs < nPatternLen)
{
switch (*szPatternW)
switch (szPatternW[nPatternOfs])
{
case L'*':
// match anything except . after /
Expand Down Expand Up @@ -208,8 +208,9 @@ BOOL GitWildcardMatch(_In_ LPCWSTR szTextW, _In_ SIZE_T nTextLen, _In_ LPCWSTR s
if ((dwLastChr < 0xFFFFFFFFUL &&
szPatternW[nPatternOfs] == L'-' &&
nPatternOfs + 1 < nPatternLen && szPatternW[nPatternOfs + 1] != L']')
? (CharToUpperW(*szTextW) <= CharToUpperW(*++szPatternW) && (DWORD)CharToUpperW(*szTextW) >= dwLastChr)
: (CharToUpperW(*szTextW) == CharToUpperW(*szPatternW)))
? (CharToUpperW(szTextW[nTextOfs]) <= CharToUpperW(szPatternW[++nPatternOfs]) &&
(DWORD)CharToUpperW(szTextW[nTextOfs]) >= dwLastChr)
: (CharToUpperW(szTextW[nTextOfs]) == CharToUpperW(szPatternW[nPatternOfs])))
{
bMatched = TRUE;
}
Expand All @@ -226,7 +227,7 @@ BOOL GitWildcardMatch(_In_ LPCWSTR szTextW, _In_ SIZE_T nTextLen, _In_ LPCWSTR s
// // literal match \-escaped character
// if (nPatternOfs + 1 < nPatternLen)
// nPatternOfs++;
// //fallthrough
// //fall through

default:
// match the current non-NUL character
Expand Down

0 comments on commit 8fd14fc

Please sign in to comment.