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

Fix panic 'integer divide by zero' when terminal width too low #137

Merged
merged 1 commit into from
Dec 8, 2017

Conversation

fxaguessy
Copy link
Contributor

In awless, when the terminal width is too low we get a panic in readline:

panic: runtime error: integer divide by zero

goroutine 24 [running]:
github.com/wallix/awless/vendor/github.com/chzyer/readline.(*opCompleter).CompleteRefresh(0xc4200a4460)
	/Users/fx/go_workspace/src/github.com/wallix/awless/vendor/github.com/chzyer/readline/complete.go:206 +0x88e
github.com/wallix/awless/vendor/github.com/chzyer/readline.(*opCompleter).EnterCompleteMode(0xc4200a4460, 0x0, 0xc4200ea300, 0x18, 0x20)
	/Users/fx/go_workspace/src/github.com/wallix/awless/vendor/github.com/chzyer/readline/complete.go:269 +0x61
github.com/wallix/awless/vendor/github.com/chzyer/readline.(*opCompleter).OnComplete(0xc4200a4460, 0xc420b58a20)
	/Users/fx/go_workspace/src/github.com/wallix/awless/vendor/github.com/chzyer/readline/complete.go:109 +0x25b
github.com/wallix/awless/vendor/github.com/chzyer/readline.(*Operation).ioloop(0xc4200a4150)
	/Users/fx/go_workspace/src/github.com/wallix/awless/vendor/github.com/chzyer/readline/operation.go:178 +0xf16
created by github.com/wallix/awless/vendor/github.com/chzyer/readline.NewOperation
	/Users/fx/go_workspace/src/github.com/wallix/awless/vendor/github.com/chzyer/readline/operation.go:88 +0x34d

This is due to the fact that terminal width gets lower than colWidth, so colNum == 0. This PR fixes this bug.

@chzyer chzyer merged commit 40d6036 into chzyer:master Dec 8, 2017
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.

2 participants