-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Fix #7570: Support address-of operator on variables in getBufferSize()
#7767
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
|
Thanks for your contribution. |
This patch didn't consider that because
Should we remove |
Ok, so maybe we should add a negative test/TODO for that case?
Ideally we would say 'Variable' for &i and just mention |
I mean something like this, it's not triggered now. And also, there is a |
lib/checkbufferoverrun.cpp
Outdated
| if (!tok->isUnaryOp("&")) | ||
| return tok; | ||
|
|
||
| const auto* op = tok->astOperand1(); |
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.
Please use Token here since it's not much longer than auto.
danmar
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.
could you run the tools/test-my-pr.py script please? to see what warnings this will produce and then we can see if there are false positives.
try to run it yourself first. if you have trouble to run it maybe we can run it on some vm.. maybe you can run on 1000 packages or something like that.. |
I try to run it locally, but it seems will take a long time since my cpu only has 6 cores and 12 threads. |
|
|
I merged this. Thank you for your contribution! Is your name listed in our AUTHORS file? Otherwise can you create a PR that adds your name to AUTHORS please? |
My pleasure! That's my first commit to cppcheck, i just create #7858. |



Detect address-of token in
getBufferSize()and get the underlying variable's corresponding buffer size.stringNotZeroTerminated()also callsgetBuffersize(), so it will also benefit.