Skip to content

Commit

Permalink
Don't try indexing backward in strings if they are 0-length
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanuber committed Apr 12, 2014
1 parent 4cddc14 commit f0fd2e8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion columnize.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func Format(input interface{}, config *Config) (string, error) {
}

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

Expand Down

0 comments on commit f0fd2e8

Please sign in to comment.