-
Notifications
You must be signed in to change notification settings - Fork 2
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
Improve safety of the C interface implementation #37
Conversation
Codecov ReportAttention: Patch coverage is
|
} | ||
|
||
if !s.is_null() { |
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.
We are already dereferencing this pointer before this point anyway, so s
has to be a non-NULL pointer to not have UB. And if allocation failed, we should return BZ_MEM_ERROR
before this. No need to check for NULL again.
} | ||
s.arr1.dealloc(bzfree, strm.opaque); | ||
s.arr2.dealloc(bzfree, strm.opaque); | ||
s.ftab.dealloc(bzfree, strm.opaque); |
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.
dealloc
checks if the value exists before deallocating.
This avoid self-referential types
No description provided.