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

termui: fix a crash when trying to open a bug when there are none #378

Merged
merged 1 commit into from Apr 16, 2020

Conversation

vojta001
Copy link
Contributor

Nothing prevented you from pressing Enter in bug listing even when there
were no open bugs. Doing so resulted in:

panic: runtime error: index out of range [0] with length 0

goroutine 1 [running]:
github.com/MichaelMure/git-bug/termui.(*bugTable).openBug(0xc00007aa80, 0xc000354000, 0xc00036c120, 0x2, 0x2)
/build/source/termui/bug_table.go:440 +0x17f
github.com/awesome-gocui/gocui.(*Gui).execKeybinding(0xc000354000, 0xc00036c120, 0xc0003102a0, 0xc00007a001, 0xc000225b2c, 0xc000000180)
/build/go/pkg/mod/github.com/awesome-gocui/gocui@v0.6.1-0.20191115151952-a34ffb055986/gui.go:808 +0x65
github.com/awesome-gocui/gocui.(*Gui).execKeybindings(0xc000354000, 0xc00036c120, 0xc000225b38, 0x3, 0x4, 0x3)
/build/go/pkg/mod/github.com/awesome-gocui/gocui@v0.6.1-0.20191115151952-a34ffb055986/gui.go:787 +0xed
github.com/awesome-gocui/gocui.(*Gui).onKey(0xc000354000, 0xc000225b38, 0x2, 0x0)
/build/go/pkg/mod/github.com/awesome-gocui/gocui@v0.6.1-0.20191115151952-a34ffb055986/gui.go:745 +0x164
github.com/awesome-gocui/gocui.(*Gui).handleEvent(...)
/build/go/pkg/mod/github.com/awesome-gocui/gocui@v0.6.1-0.20191115151952-a34ffb055986/gui.go:506
github.com/awesome-gocui/gocui.(*Gui).MainLoop(0xc000354000, 0x0, 0x0)
/build/go/pkg/mod/github.com/awesome-gocui/gocui@v0.6.1-0.20191115151952-a34ffb055986/gui.go:466 +0x202
github.com/MichaelMure/git-bug/termui.initGui(0x0)
/build/source/termui/termui.go:113 +0x12c
github.com/MichaelMure/git-bug/termui.Run(0xc000228000, 0xc000078b30, 0x0)
/build/source/termui/termui.go:66 +0x185
github.com/MichaelMure/git-bug/commands.runTermUI(0x1211bc0, 0x12478e0, 0x0, 0x0, 0x0, 0x0)
/build/source/commands/termui.go:18 +0xd5
github.com/spf13/cobra.(*Command).execute(0x1211bc0, 0x12478e0, 0x0, 0x0, 0x1211bc0, 0x12478e0)
/build/go/pkg/mod/github.com/spf13/cobra@v0.0.6/command.go:840 +0x453
github.com/spf13/cobra.(*Command).ExecuteC(0x1210960, 0x0, 0x0, 0x0)
/build/go/pkg/mod/github.com/spf13/cobra@v0.0.6/command.go:945 +0x317
github.com/spf13/cobra.(*Command).Execute(...)
/build/go/pkg/mod/github.com/spf13/cobra@v0.0.6/command.go:885
github.com/MichaelMure/git-bug/commands.Execute()
/build/source/commands/root.go:54 +0x2d
main.main()
/build/source/git-bug.go:14 +0x20

Nothing prevented you from pressing Enter in bug listing even when there
were no open bugs. Doing so resulted in:

panic: runtime error: index out of range [0] with length 0

goroutine 1 [running]:
github.com/MichaelMure/git-bug/termui.(*bugTable).openBug(0xc00007aa80, 0xc000354000, 0xc00036c120, 0x2, 0x2)
        /build/source/termui/bug_table.go:440 +0x17f
github.com/awesome-gocui/gocui.(*Gui).execKeybinding(0xc000354000, 0xc00036c120, 0xc0003102a0, 0xc00007a001, 0xc000225b2c, 0xc000000180)
        /build/go/pkg/mod/github.com/awesome-gocui/gocui@v0.6.1-0.20191115151952-a34ffb055986/gui.go:808 +0x65
github.com/awesome-gocui/gocui.(*Gui).execKeybindings(0xc000354000, 0xc00036c120, 0xc000225b38, 0x3, 0x4, 0x3)
        /build/go/pkg/mod/github.com/awesome-gocui/gocui@v0.6.1-0.20191115151952-a34ffb055986/gui.go:787 +0xed
github.com/awesome-gocui/gocui.(*Gui).onKey(0xc000354000, 0xc000225b38, 0x2, 0x0)
        /build/go/pkg/mod/github.com/awesome-gocui/gocui@v0.6.1-0.20191115151952-a34ffb055986/gui.go:745 +0x164
github.com/awesome-gocui/gocui.(*Gui).handleEvent(...)
        /build/go/pkg/mod/github.com/awesome-gocui/gocui@v0.6.1-0.20191115151952-a34ffb055986/gui.go:506
github.com/awesome-gocui/gocui.(*Gui).MainLoop(0xc000354000, 0x0, 0x0)
        /build/go/pkg/mod/github.com/awesome-gocui/gocui@v0.6.1-0.20191115151952-a34ffb055986/gui.go:466 +0x202
github.com/MichaelMure/git-bug/termui.initGui(0x0)
        /build/source/termui/termui.go:113 +0x12c
github.com/MichaelMure/git-bug/termui.Run(0xc000228000, 0xc000078b30, 0x0)
        /build/source/termui/termui.go:66 +0x185
github.com/MichaelMure/git-bug/commands.runTermUI(0x1211bc0, 0x12478e0, 0x0, 0x0, 0x0, 0x0)
        /build/source/commands/termui.go:18 +0xd5
github.com/spf13/cobra.(*Command).execute(0x1211bc0, 0x12478e0, 0x0, 0x0, 0x1211bc0, 0x12478e0)
        /build/go/pkg/mod/github.com/spf13/cobra@v0.0.6/command.go:840 +0x453
github.com/spf13/cobra.(*Command).ExecuteC(0x1210960, 0x0, 0x0, 0x0)
        /build/go/pkg/mod/github.com/spf13/cobra@v0.0.6/command.go:945 +0x317
github.com/spf13/cobra.(*Command).Execute(...)
        /build/go/pkg/mod/github.com/spf13/cobra@v0.0.6/command.go:885
github.com/MichaelMure/git-bug/commands.Execute()
        /build/source/commands/root.go:54 +0x2d
main.main()
        /build/source/git-bug.go:14 +0x20
@MichaelMure MichaelMure merged commit 4242150 into MichaelMure:master Apr 16, 2020
@MichaelMure
Copy link
Owner

Thanks :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants