-
Notifications
You must be signed in to change notification settings - Fork 1.9k
C++: Promote cpp/guarded-free out of experimental
#18111
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
Conversation
|
QHelp previews: cpp/ql/src/Best Practices/GuardedFree.qhelpGuarded FreeThe RecommendationA function call to Examplevoid test()
{
char *foo = malloc(100);
// BAD
if (foo)
free(foo);
// GOOD
free(foo);
}In this example, the condition checking the value of References
|
cpp/guarded-freecpp/guarded-free out of experimental
geoffw0
left a comment
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.
Changes LGTM. A sample of the new DCA results LGTM.
We could replace FreeCall with DeallocationExpr and fc.getArgument(0) with fc.getFreedExpr(), to add results for all kinds of free variants including, I think, delete. This is assuming we're confident all of these variants are in fact safe on NULL. It probably makes sense to promote the query as it is and consider this as a follow-up step afterwards?
Needs a docs review.
That would have my preference. |
|
I'll review this on behalf of Docs. |
mchammer01
left a comment
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.
LGTM ✨
Approving this but left a few comments and suggestions following editorial review.
Co-authored-by: mc <42146119+mchammer01@users.noreply.github.com>
Co-authored-by: mc <42146119+mchammer01@users.noreply.github.com>
Co-authored-by: mc <42146119+mchammer01@users.noreply.github.com>
Thanks for the review and the suggestions! |
|
@geoffw0 Would you mind re-approving so we can merge this? |
geoffw0
left a comment
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.
👍
Pull Request checklist
All query authors
.qhelp. See the documentation in this repository.Internal query authors only
.ql,.qll, or.qhelpfiles. See the documentation (internal access required).