Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: correct json_rpc_buffer initialization order #473

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

tdb3
Copy link
Contributor

@tdb3 tdb3 commented Nov 11, 2024

While reviewing #471, noticed that json_rpc_buffer initialization tries to memset before checking if the malloc was successful.

This moves the memset after the check.

Did a basic test by building and running on a Supra 401. Started mining on testnet4 on a ckpool instance. Jobs were received and shares were accepted.

Note: The malloc failure is unlikely to occur, so we're not seeing an issue now, but if it does occur (e.g. other future code changes chew up too much heap), then we could actually see the error in the log.

Performs memset after checking if the malloc was successful.
Safer, avoids segfault on (unlikely) unsuccessful malloc,
and allows the error printing to occur.
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.

1 participant