Skip to content

Commit

Permalink
Avoid potential out-of-range access if string is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
twpayne committed Jan 15, 2019
1 parent 12c3b1f commit e0b7bad
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions cmd/os_release.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ func parseOSRelease(r io.Reader) (map[string]string, error) {

// titilize returns s, titilized.
func titilize(s string) string {
if s == "" {
return s
}
runes := []rune(s)
return string(append([]rune{unicode.ToTitle(runes[0])}, runes[1:]...))
}
Expand Down

0 comments on commit e0b7bad

Please sign in to comment.