From 1b5d8b0b9b6a706619c34d7a97fc144a941c851d Mon Sep 17 00:00:00 2001 From: Dave Chen Date: Sat, 2 Apr 2022 16:29:40 +0800 Subject: [PATCH] Fix the nil pointer dereference for comformance spec validation `verify-conformance-yaml.sh` is used to verify the test spec of conformance e2e test are valid. Bascically, it calls `e2e.test` binary to dump the test spec and then walk the source to generate the `conformance.yaml`. If the `e2e.test` binary is outdated, it's possible that `testInfo` is nil. Access the field from nil will result to `nil pointer dereference` Signed-off-by: Dave Chen --- test/conformance/walk.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/test/conformance/walk.go b/test/conformance/walk.go index d31d66883a8..70cd5a37c6a 100644 --- a/test/conformance/walk.go +++ b/test/conformance/walk.go @@ -108,10 +108,9 @@ func main() { testInfo := getTestInfo(spec) if testInfo != nil { testInfos = append(testInfos, testInfo) - } - - if err := validateTestName(testInfo.CodeName); err != nil { - log.Fatal(err) + if err := validateTestName(testInfo.CodeName); err != nil { + log.Fatal(err) + } } } }