aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--repository.go3
-rw-r--r--repository_test.go5
2 files changed, 8 insertions, 0 deletions
diff --git a/repository.go b/repository.go
index e8eb53f..7292df6 100644
--- a/repository.go
+++ b/repository.go
@@ -280,6 +280,9 @@ func dotGitToOSFilesystems(path string, detect bool) (dot, wt billy.Filesystem,
pathinfo, err := fs.Stat("/")
if !os.IsNotExist(err) {
+ if pathinfo == nil {
+ return nil, nil, err
+ }
if !pathinfo.IsDir() && detect {
fs = osfs.New(filepath.Dir(path))
}
diff --git a/repository_test.go b/repository_test.go
index e284df8..7a9db15 100644
--- a/repository_test.go
+++ b/repository_test.go
@@ -2948,6 +2948,11 @@ func (s *RepositorySuite) TestBrokenMultipleShallowFetch(c *C) {
c.Assert(err, IsNil)
}
+func (s *RepositorySuite) TestDotGitToOSFilesystemsInvalidPath(c *C) {
+ _, _, err := dotGitToOSFilesystems("\000", false)
+ c.Assert(err, NotNil)
+}
+
func BenchmarkObjects(b *testing.B) {
defer fixtures.Clean()