1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

strings.Split may return an empty string on no match

* This fixes an index out of range crash if cgroup memory is not
  enabled.
This commit is contained in:
Harley Laue 2013-05-02 14:44:41 -05:00
parent ff5e238de9
commit 4bc8ef42d4

View file

@ -445,7 +445,7 @@ func FindCgroupMountpoint(cgroupType string) (string, error) {
// cgroup /sys/fs/cgroup/devices cgroup rw,relatime,devices 0 0
for _, line := range strings.Split(string(output), "\n") {
parts := strings.Split(line, " ")
if parts[2] == "cgroup" {
if len(parts) > 1 && parts[2] == "cgroup" {
for _, opt := range strings.Split(parts[3], ",") {
if opt == cgroupType {
return parts[1], nil