-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Avoid using uninitialised struct #12046
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
What are these scenarios you mentioned? |
For example, in |
Thanks for the PR. I reviewed it now. What you are proposing is not the correct solution. We do not initialize structs with What you found is indeed a bug. We are calling |
f482695
to
e312c65
Compare
Hi @kamil-tekiela, thank you for the comment. I updated the PR as you were suggesting. |
ext/mysqlnd/mysqlnd_wireprotocol.h
Outdated
@@ -34,7 +34,7 @@ PHPAPI extern const char mysqlnd_read_body_name[]; | |||
#define PACKET_FREE(packet) \ | |||
do { \ | |||
DBG_INF_FMT("PACKET_FREE(%p)", packet); \ | |||
if ((packet)->header.m->free_mem) { \ | |||
if ((packet)->header.m && (packet)->header.m->free_mem) { \ |
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.
This is not needed. It is already guaranteed.
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.
Removed
e312c65
to
140ce55
Compare
Looks right to me too, but hasn't been committed yet. |
In some scenarios, there is a possibility that PACKET_FREE will be called with an uninitialised
fields_eof
.Added some sanity to avoid negative impact of such an event