chore: fix potential nil pointer errors (#3454)

This commit is contained in:
Kevin Wan
2023-07-30 21:37:41 +08:00
committed by GitHub
parent ad4cce959d
commit c3f57e9b0a
7 changed files with 40 additions and 11 deletions

View File

@@ -79,7 +79,7 @@ func SetMapIndexValue(tp reflect.Type, value, key, target reflect.Value) {
}
// ValidatePtr validates v if it's a valid pointer.
func ValidatePtr(v *reflect.Value) error {
func ValidatePtr(v reflect.Value) error {
// sequence is very important, IsNil must be called after checking Kind() with reflect.Ptr,
// panic otherwise
if !v.IsValid() || v.Kind() != reflect.Ptr || v.IsNil() {