-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
C++: Promote cpp/guarded-free
out of experimental
#18111
base: main
Are you sure you want to change the base?
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-free
cpp/guarded-free
out of experimental
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. |
Pull Request checklist
All query authors
.qhelp
. See the documentation in this repository.Internal query authors only
.ql
,.qll
, or.qhelp
files. See the documentation (internal access required).