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

Introduce unique_cstr. #3245

Merged
merged 8 commits into from
Nov 27, 2024
Merged

Introduce unique_cstr. #3245

merged 8 commits into from
Nov 27, 2024

Conversation

1uc
Copy link
Collaborator

@1uc 1uc commented Nov 25, 2024

This commit adds a RAII wrapper for C-strings, called unique_cstr. Several places in the NRN Python bindings use char * when owning a malloc allocated string.

This new class is then used to prevent leaking HOC strings on error paths, see #1437

Copy link

✔️ 5b6bf9d -> Azure artifacts URL

Copy link

codecov bot commented Nov 25, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 67.09%. Comparing base (5f0675b) to head (9ed485b).
Report is 2 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #3245   +/-   ##
=======================================
  Coverage   67.09%   67.09%           
=======================================
  Files         570      571    +1     
  Lines      111082   111089    +7     
=======================================
+ Hits        74525    74532    +7     
  Misses      36557    36557           

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

@bbpbuildbot

This comment has been minimized.

@1uc 1uc marked this pull request as ready for review November 25, 2024 09:11
Copy link
Collaborator

@matz-e matz-e left a comment

Choose a reason for hiding this comment

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

Nice work!

@1uc 1uc marked this pull request as draft November 25, 2024 10:57
@1uc
Copy link
Collaborator Author

1uc commented Nov 25, 2024

The difficulty is this line here:

if (narg != 1) {
hoc_execerror("must be one argument for", self->sym_->name);
}

it leaks all strings stored in strings_to_free. The question is: intentionally or by accident?

@1uc 1uc marked this pull request as ready for review November 26, 2024 07:12
@bbpbuildbot

This comment has been minimized.

src/neuron/unique_cstr.hpp Show resolved Hide resolved
This commit adds a RAII wrapper for C-strings, called `unique_cstr`.
Several places in the NRN Python bindings use `char *` when owning a
malloc allocated string.

This new class is then used to prevent leaking HOC strings on error
paths.
Copy link

sonarcloud bot commented Nov 27, 2024

Copy link

✔️ 9ed485b -> Azure artifacts URL

@1uc 1uc merged commit 12cc270 into master Nov 27, 2024
35 checks passed
@1uc 1uc deleted the 1uc/unique_cstr branch November 27, 2024 20:55
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