Skip to content

Fix crash when calling `path` without arguments.

Florian Karuhtz requested to merge (removed):flesser-master-patch-79250 into master

When (illegally) calling path without any argument, reposurgeoun would crash:

reposurgeon% path
panic: runtime error: index out of range [0] with length 0 [recovered]
        panic: runtime error: index out of range [0] with length 0 [recovered]
        panic: runtime error: index out of range [0] with length 0

goroutine 1 [running]:
main.main.func1()
        /home/florian/projects/reposurgeon/surgeon/reposurgeon.go:7521 +0x354
panic(0x91c4a0, 0xc001662018)
        /usr/local/go/src/runtime/panic.go:965 +0x1b9
main.catch(0x94f366, 0x7, 0x91c4a0, 0xc001662018, 0x1)
        /home/florian/projects/reposurgeon/surgeon/inner.go:129 +0x1a5
main.(*Reposurgeon).SetCore.func1.1(0xc0004afc88)
        /home/florian/projects/reposurgeon/surgeon/reposurgeon.go:466 +0x5c
panic(0x91c4a0, 0xc001662018)
        /usr/local/go/src/runtime/panic.go:965 +0x1b9
main.(*Reposurgeon).DoPath(0xc000210000, 0xc0005380f0, 0x0, 0x0)
        /home/florian/projects/reposurgeon/surgeon/reposurgeon.go:4316 +0x654
gitlab.com/ianbruene/kommandant.(*Kmdt).bind.func1(0xa0e5d0, 0xc0001e0660, 0xc0005380f0, 0x0, 0xd2aa30)
        /home/florian/go/pkg/mod/gitlab.com/ianbruene/kommandant@v0.6.2/kommandant.go:296 +0x73
gitlab.com/ianbruene/kommandant.(*Kmdt).OneCmd_core(0xc0002162c0, 0xa0e5d0, 0xc0001e0660, 0xc0005380f0, 0x4, 0x0)
        /home/florian/go/pkg/mod/gitlab.com/ianbruene/kommandant@v0.6.2/kommandant.go:711 +0x422
main.(*Reposurgeon).SetCore.func1(0xa0e5d0, 0xc0001e0660, 0xc0005380f0, 0x4, 0x0)
        /home/florian/projects/reposurgeon/surgeon/reposurgeon.go:471 +0x85
gitlab.com/ianbruene/kommandant.(*Kmdt).OneCmd(0xc0002162c0, 0xa0e5d0, 0xc0001e0660, 0xc0005380f0, 0x4, 0xc0005380f0)
        /home/florian/go/pkg/mod/gitlab.com/ianbruene/kommandant@v0.6.2/kommandant.go:251 +0x142
gitlab.com/ianbruene/kommandant.(*Kmdt).CmdLoop(0xc0002162c0, 0xa0e5d0, 0xc0001e0660, 0x0, 0x0)
        /home/florian/go/pkg/mod/gitlab.com/ianbruene/kommandant@v0.6.2/kommandant.go:636 +0x245
main.main()
        /home/florian/projects/reposurgeon/surgeon/reposurgeon.go:7552 +0x505

Merge request reports