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 a few potential null derefs in bootstrap daemon. #2662

Merged
merged 1 commit into from
Feb 9, 2024

Conversation

iphydf
Copy link
Member

@iphydf iphydf commented Feb 9, 2024

Found by PVS Studio.


This change is Reviewable

@iphydf iphydf added this to the v0.2.19 milestone Feb 9, 2024
@iphydf iphydf marked this pull request as ready for review February 9, 2024 00:48
Copy link

codecov bot commented Feb 9, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (b9877b3) 73.69% compared to head (08d3393) 73.72%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2662      +/-   ##
==========================================
+ Coverage   73.69%   73.72%   +0.02%     
==========================================
  Files         148      148              
  Lines       30479    30479              
==========================================
+ Hits        22461    22470       +9     
+ Misses       8018     8009       -9     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@nurupo nurupo left a comment

Choose a reason for hiding this comment

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

Reviewed 2 of 2 files at r1, all commit messages.
Reviewable status: :shipit: complete! 1 of 1 approvals obtained (waiting on @iphydf)


other/bootstrap_daemon/src/config.c line 82 at r1 (raw file):

Previously, iphydf wrote…

I'm actually not certain about this. It seems to me that this realloc always resizes down? Why do we do this at all?

Yep, it always downsizes, and yes, it is not really necessary. The array is short-lived, it's freed in the main() after passing the ports to new_tcp_server(), before entering the main loop, so this is a rather pointless attempt at memory optimization.

Feel free to remove it. The same for the similar realloc blow.

@iphydf iphydf force-pushed the malloc-returns-null branch from 9a36d44 to 08d3393 Compare February 9, 2024 18:00
Copy link
Member Author

@iphydf iphydf left a comment

Choose a reason for hiding this comment

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

Reviewable status: :shipit: complete! 1 of 1 approvals obtained


other/bootstrap_daemon/src/config.c line 82 at r1 (raw file):

Previously, nurupo wrote…

Yep, it always downsizes, and yes, it is not really necessary. The array is short-lived, it's freed in the main() after passing the ports to new_tcp_server(), before entering the main loop, so this is a rather pointless attempt at memory optimization.

Feel free to remove it. The same for the similar realloc blow.

Done.

@iphydf iphydf merged commit 08d3393 into TokTok:master Feb 9, 2024
60 of 61 checks passed
@iphydf iphydf deleted the malloc-returns-null branch February 9, 2024 18:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants