Skip to content

Commit f0fd2e8

Browse files
committed
Don't try indexing backward in strings if they are 0-length
1 parent 4cddc14 commit f0fd2e8

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

columnize.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ func Format(input interface{}, config *Config) (string, error) {
9595
}
9696

9797
// Remove trailing newline without removing leading/trailing space
98-
if n := len(result); result[n-1] == '\n' {
98+
if n := len(result); n > 0 && result[n-1] == '\n' {
9999
result = result[:n-1]
100100
}
101101

0 commit comments

Comments
 (0)