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

Set fields to NULL after free in freeClient() #1279

Merged
merged 1 commit into from
Nov 11, 2024

Conversation

QuChen88
Copy link
Contributor

@QuChen88 QuChen88 commented Nov 8, 2024

Null out several references after freeing the object in freeClient().

This is just to make the code more safe, to protect against use-after-free for future changes.

Copy link
Contributor

@hpatro hpatro left a comment

Choose a reason for hiding this comment

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

Did it cause a double free or use-after-free somewhere we would need to fix?

@QuChen88
Copy link
Contributor Author

QuChen88 commented Nov 8, 2024

I didn't spot an issue in OSS. This change is just to enforce some best practices of setting the pointer references to NULL after freeing the object to avoid future mistakes like such.

We did this change internally in our code base, so I figured it is better to open source it.

Copy link

codecov bot commented Nov 9, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 70.69%. Comparing base (9f4b1ad) to head (abd5f49).
Report is 169 commits behind head on unstable.

Additional details and impacted files
@@             Coverage Diff              @@
##           unstable    #1279      +/-   ##
============================================
+ Coverage     70.60%   70.69%   +0.09%     
============================================
  Files           112      114       +2     
  Lines         61533    63154    +1621     
============================================
+ Hits          43446    44648    +1202     
- Misses        18087    18506     +419     
Files with missing lines Coverage Δ
src/networking.c 88.65% <100.00%> (-0.18%) ⬇️

... and 97 files with indirect coverage changes

@zuiderkwast zuiderkwast changed the title Reset some fields in freeClient(). Set fields to NULL after free in freeClient() Nov 11, 2024
@zuiderkwast zuiderkwast merged commit 9300a7e into valkey-io:unstable Nov 11, 2024
48 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.

4 participants