From 1ec25d17d11560a9186e346aacab190c955fac3e Mon Sep 17 00:00:00 2001 From: sina haseli Date: Wed, 18 Dec 2024 20:11:09 +0330 Subject: [PATCH] Fix nil pointer dereference in GetBinary (Fixes #264) (#265) * Fix nil pointer dereference in GetBinary (Fixes #264) * fixed DataBytesOrJson nil check --------- Co-authored-by: sina haseli --- rpc/types.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/rpc/types.go b/rpc/types.go index 0de139ca..e00d44c6 100644 --- a/rpc/types.go +++ b/rpc/types.go @@ -376,6 +376,9 @@ func (wrap *DataBytesOrJSON) UnmarshalJSON(data []byte) error { // GetBinary returns the decoded bytes if the encoding is // "base58", "base64", or "base64+zstd". func (dt *DataBytesOrJSON) GetBinary() []byte { + if dt == nil { + return nil + } return dt.asDecodedBinary.Content }