Skip to content

Commit

Permalink
graphql: protect against nil pointer deref on cases like TX with nil … (
Browse files Browse the repository at this point in the history
erigontech#7047)

…To address (contract creation)
  • Loading branch information
SLoeuillet authored and Alexey Sharp committed Mar 7, 2023
1 parent c9513f5 commit 94b4cee
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 55 deletions.
5 changes: 5 additions & 0 deletions cmd/rpcdaemon/graphql/graph/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ import (
func convertDataToStringP(abstractMap map[string]interface{}, field string) *string {
var result string

if reflect.ValueOf(abstractMap[field]).IsZero() {
return nil
}

switch v := abstractMap[field].(type) {
case int64:
result = strconv.FormatInt(v, 10)
Expand Down Expand Up @@ -44,6 +48,7 @@ func convertDataToStringP(abstractMap map[string]interface{}, field string) *str
fmt.Println("unhandled/string", reflect.TypeOf(abstractMap[field]), field, abstractMap[field])
result = "unhandled"
}

return &result
}

Expand Down
126 changes: 71 additions & 55 deletions cmd/rpcdaemon/graphql/graph/schema.resolvers.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 94b4cee

Please sign in to comment.