-
Notifications
You must be signed in to change notification settings - Fork 1.3k
fix possible NULL pointer dereference after call to configASSERT() #1284
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
Compiling with clang static code analysis, possible NULL pointer dereference are found. Since configASSERT() can possibly return and continue "normal" operation, the code in queue.c and stream_buffer.c can be adjusted to avoid NULL pointer exceptions. Signed-off-by: Florian La Roche <[email protected]>
|
This implementation allows developers to halt execution at the point of failure and use their debugger to examine the call stack, helping identify the root cause of the assertion failure. |
Your changes generally seem to be The overall affect regardless is nil, however. Are you saying that clang static analysis no longer produces warnings with your changes, because I don't see the difference. |
Hello Abdullah Almosalami, clang assumes that after one assert it is possible to then continue code execution and this Another option for the compiler would be to change the assert function to be no-return, Regarding "configASSERT( ptr ) → configASSERT( ptr != NULL )". I just thought that the longer best regards, Florian La Roche |
Hmm... I'm not seeing how your changes avoid null pointer exceptions. There are no additional checks; just combining multiple assert conditions into one and using |
Consider the following: configASSERT( pxQueue != NULL );
configASSERT( pxQueue->uxItemSize != 0U ); If the first assertion allows execution to continue when Combining them using a logical AND operator ensures that the second expression is not evaluated if the first one is false: configASSERT( ( pxQueue != NULL ) && ( pxQueue->uxItemSize != 0U ) ); This works because C's short-circuit evaluation guarantees that if |
@laroche What do you think about my comment - #1284 (comment)? |
@aggarg Yup, makes sense. I was assuming the asserts don't return if conditions are |
Hello all, My current thinking is this:
Anyway, it is your decision and I am fine with either way you decide. greetings and best regards, Florian La Roche |
Agree that this changes does not have any drawback. |
Compiling with clang static code analysis, possible NULL pointer dereference are found. Since configASSERT() can possibly return and continue "normal" operation, the code in queue.c and stream_buffer.c can be adjusted to avoid NULL pointer exceptions.
Description
Test Steps
Checklist:
Related Issue
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.