Skip to content

Potential nil dereference

Description

The code may dereference a nil pointer, potentially causing a runtime error. This can occur when a function call is made on an object that has not been checked for nil.

Examples

Insecure Code

go
foo.bar()
if foo != nil {
    // code
}

Secure Code

go
if foo != nil {
    foo.bar()
    // code
}

Remediation

Check for nil before calling methods on an object

Rule Details

FieldValue
IDCODE-0465
CategoryGeneric
SeverityMEDIUM
CWECWE-253
ConfidenceMEDIUM
ImpactMEDIUM
LikelihoodMEDIUM
ExploitabilityEASY
Tagsnil dereference
OWASPN/A

References