浏览代码

strings.Split may return an empty string on no match

* This fixes an index out of range crash if cgroup memory is not
  enabled.
Harley Laue 12 年之前
父节点
当前提交
4bc8ef42d4
共有 1 个文件被更改,包括 1 次插入1 次删除
  1. 1 1
      utils.go

+ 1 - 1
utils.go

@@ -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