Skip to content

Commit

Permalink
fix(bindnode): panic early if API has been passed ptr-to-ptr
Browse files Browse the repository at this point in the history
  • Loading branch information
rvagg committed May 23, 2022
1 parent eca717f commit e01280e
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions node/bindnode/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ func Prototype(ptrType interface{}, schemaType schema.Type) schema.TypedPrototyp
panic("bindnode: ptrType must be a pointer")
}
goType = goPtrType.Elem()
if goType.Kind() == reflect.Ptr {
panic("bindnode: ptrType must not be a pointer to a pointer")
}

if schemaType == nil {
schemaType = inferSchema(goType, 0)
Expand Down Expand Up @@ -75,6 +78,9 @@ func Wrap(ptrVal interface{}, schemaType schema.Type) schema.TypedNode {
panic("bindnode: ptrVal must not be nil")
}
goVal := goPtrVal.Elem()
if goVal.Kind() == reflect.Ptr {
panic("bindnode: ptrVal must not be a pointer to a pointer")
}
if schemaType == nil {
schemaType = inferSchema(goVal.Type(), 0)
} else {
Expand Down

0 comments on commit e01280e

Please sign in to comment.