jsonrpc: Avoid nil pointer dereference.#2636
Merged
Merged
Conversation
davecgh
approved these changes
May 23, 2026
davecgh
left a comment
Member
There was a problem hiding this comment.
Nice. I'm guessing you noticed this after reviewing the recent dcrd PR touch RPC server things!
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".
2ffe61d to
f7fd42e
Compare
jrick
approved these changes
May 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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".