Skip to content
Snippets Groups Projects
Commit 4bc8ef42 authored by Harley Laue's avatar Harley Laue
Browse files

strings.Split may return an empty string on no match

* This fixes an index out of range crash if cgroup memory is not
  enabled.
parent ff5e238d
No related branches found
No related tags found
No related merge requests found
...@@ -445,7 +445,7 @@ func FindCgroupMountpoint(cgroupType string) (string, error) { ...@@ -445,7 +445,7 @@ func FindCgroupMountpoint(cgroupType string) (string, error) {
// cgroup /sys/fs/cgroup/devices cgroup rw,relatime,devices 0 0 // cgroup /sys/fs/cgroup/devices cgroup rw,relatime,devices 0 0
for _, line := range strings.Split(string(output), "\n") { for _, line := range strings.Split(string(output), "\n") {
parts := strings.Split(line, " ") parts := strings.Split(line, " ")
if parts[2] == "cgroup" { if len(parts) > 1 && parts[2] == "cgroup" {
for _, opt := range strings.Split(parts[3], ",") { for _, opt := range strings.Split(parts[3], ",") {
if opt == cgroupType { if opt == cgroupType {
return parts[1], nil return parts[1], nil
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment