Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash on resolving empty string #674

Closed
9seconds opened this issue Feb 2, 2023 · 0 comments · Fixed by #696
Closed

Crash on resolving empty string #674

9seconds opened this issue Feb 2, 2023 · 0 comments · Fixed by #696
Labels
bug Something isn't working

Comments

@9seconds
Copy link

9seconds commented Feb 2, 2023

Please consider this snippet:

package main

import (
	"fmt"

	"github.com/go-git/go-git/v5"
	"github.com/go-git/go-git/v5/plumbing"
)

func main() {
	repo, err := git.PlainClone("/tmp/foo", false, &git.CloneOptions{
		URL: "https://github.com/go-git/go-git",
	})
	if err != nil {
		panic(err)
	}

	fmt.Println(repo.ResolveRevision(plumbing.Revision("")))
}

If I run it:

$ go run main.go
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x73b8e6]

goroutine 1 [running]:
github.com/go-git/go-git/v5.(*Repository).ResolveRevision(0xc0001a4450, {0x0?, 0x7fc52f?})
	/home/vagrant/.asdf/installs/golang/1.19.5/packages/pkg/mod/github.com/go-git/go-git/v5@v5.5.2/repository.go:1560 +0x86
main.main()
	/repos/tt/repro.go:18 +0x9c
exit status 2
@pjbgf pjbgf added the bug Something isn't working label Mar 2, 2023
@pjbgf pjbgf closed this as completed in #696 Mar 2, 2023
pjbgf added a commit that referenced this issue Mar 2, 2023
*: Fix panic for empty revisions. Fixes #674
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants