diff options
author | Máximo Cuadros <mcuadros@gmail.com> | 2022-11-07 17:03:35 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-07 17:03:35 +0100 |
commit | 1a0530e03cdcac6af61f064e180685cf2aec2802 (patch) | |
tree | c548e89bae59426851ccf1830cbea574bfe2fa86 /plumbing/format/gitattributes/pattern.go | |
parent | f37bb587b6634435afb5069b2101cb4e0ff78d63 (diff) | |
parent | 7dd5d8f39a3c31c8257c29a8cfa4ef2cf15d4a80 (diff) | |
download | go-git-1a0530e03cdcac6af61f064e180685cf2aec2802.tar.gz |
Merge pull request #598 from To1ne/toon-fix-gitattr-crash
plumbing: gitattributes, Avoid index out of range
Diffstat (limited to 'plumbing/format/gitattributes/pattern.go')
-rw-r--r-- | plumbing/format/gitattributes/pattern.go | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/plumbing/format/gitattributes/pattern.go b/plumbing/format/gitattributes/pattern.go index d961aba..f101f47 100644 --- a/plumbing/format/gitattributes/pattern.go +++ b/plumbing/format/gitattributes/pattern.go @@ -52,6 +52,11 @@ func (p *pattern) Match(path []string) bool { var match, doublestar bool var err error for _, part := range path { + // path is deeper than pattern + if len(pattern) == 0 { + return false + } + // skip empty if pattern[0] == "" { pattern = pattern[1:] |