-
Notifications
You must be signed in to change notification settings - Fork 292
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
refactor: Make Tox_Options own the passed proxy host and savedata. #2819
base: master
Are you sure you want to change the base?
Conversation
2e5d814
to
fdd1be5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can immediately free their data and can pass temporaries to the options setters
This contradicts with:
* The setter tries to copy the string, but if it fails, the value is not * copied and this member is set to the user-provided pointer. In that * case, the user must not free the string until the Tox_Options object is * freed. Client code can check whether allocation succeeded by comparing * the value of this member to the user-provided pointer. */
Looks like the client has to check first if the copying succeeded before they free the data, so not exactly immediately, but could be close enough based on what you meant with that comment. As compared to the previous behavior, you can free it sooner, yes.
Also, if the user clones Tox_Options, freeing it will free the pointers twice.
523340a
to
ccef3ea
Compare
ccef3ea
to
87f3549
Compare
87f3549
to
c600c19
Compare
d32d4a3
to
987ad78
Compare
13df70a
to
ce30952
Compare
auto_tests/file_saving_test.c
Outdated
tox_options_set_savedata_type(options, TOX_SAVEDATA_TYPE_TOX_SAVE); | ||
|
||
tox_options_set_savedata_data(options, clear, size); | ||
tox_options_set_savedata_data(options, clear, clear_size); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be ck_assert
ed so there's no potential for a use-after-free in the test?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, good idea. Done.
386be37
to
ebe150f
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2819 +/- ##
==========================================
- Coverage 72.21% 72.18% -0.04%
==========================================
Files 151 151
Lines 31122 31176 +54
==========================================
+ Hits 22476 22505 +29
- Misses 8646 8671 +25 ☔ View full report in Codecov by Sentry. |
This way, client code can immediately free their data and can pass temporaries to the options setters.
This way, client code can immediately free their data after the options setter returns true.
This change is