Skip to content

Commit

Permalink
Fix nil pointer dereference in sysctlInspect (#340)
Browse files Browse the repository at this point in the history
Co-authored-by: hiyongliz <[email protected]>
  • Loading branch information
hiyongliz and hiyongliz authored Dec 18, 2024
1 parent d8d0e98 commit 8cc955a
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pkg/inspect/sysctl_inspect.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"encoding/json"
"fmt"

"github.com/kubesphere/event-rule-engine/visitor"
kubeeyev1alpha2 "github.com/kubesphere/kubeeye/apis/kubeeye/v1alpha2"
"github.com/kubesphere/kubeeye/pkg/constant"
Expand Down Expand Up @@ -106,7 +107,7 @@ func (o *sysctlInspect) GetResult(runNodeName string, resultCm *corev1.ConfigMap
}

func parseSysctlVal(val []string) string {
if len(val) == 0 && val == nil {
if len(val) == 0 || val == nil {
return ""
}
return val[0]
Expand Down

0 comments on commit 8cc955a

Please sign in to comment.