Skip to content

jsonrpc: Avoid nil pointer dereference.#2636

Merged
jrick merged 1 commit into
decred:masterfrom
jholdstock:dont-deref-nil
May 27, 2026
Merged

jsonrpc: Avoid nil pointer dereference.#2636
jrick merged 1 commit into
decred:masterfrom
jholdstock:dont-deref-nil

Conversation

@jholdstock

Copy link
Copy Markdown
Member

This avoids a number of nil pointer dereferences by adding !nil checks before dereferencing. These checks are required for fields that are tagged with "jsonrpcdefault" because those fields will only have their default value if they have been omitted from the json string, not if they are explicitly set to "null".

@davecgh davecgh left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. I'm guessing you noticed this after reviewing the recent dcrd PR touch RPC server things!

@jrick jrick left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good fixes overall

Comment thread internal/rpc/jsonrpc/methods.go Outdated
This avoids a number of nil pointer dereferences by adding !nil checks
before dereferencing. These checks are required for fields that are
tagged with "jsonrpcdefault" because those fields will only have their
default value if they have been omitted from the json string, not if
they are explicitly set to "null".
@jrick jrick merged commit 43b095a into decred:master May 27, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants