Repository navigation
Add NULL-pointer assertion for pxList in vListInsert - #1532
Open
aniruddhajoshi876 wants to merge 10 commits into
Open
aniruddhajoshi876 wants to merge 10 commits into
aniruddhajoshi876 wants to merge 10 commits into
Conversation
Add assertion to check for null stream buffer
Fix formatting and assertions in listREMOVE_ITEM macro
Added detailed comments regarding stack initialization and buffer guarantees.
Restore listREMOVE_ITEM line continuations, add missing semicolon, place asserts after declarations (C90), and revert unrelated tasks.c and MSVC-MingW port changes.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary
Adds
configASSERT( pxList != NULL )tovListInsert(), beforepxListis first dereferenced.Motivation
While debugging my application, I encountered a case where custom event-handling code attempted to insert an item into a list before the list pointer had been assigned. The pointer was NULL when passed to
vListInsert(), resulting in a HardFault during list traversal.The fault occurred inside the kernel rather than at the point where the invalid argument entered the function, making the cause harder to identify. This motivated me to add
configASSERT( pxList != NULL )before the first dereference. With assertions enabled, this catches the invalid argument at the function boundary and provides a clearer starting point for debugging.The assertion does not fix the underlying application error or detect every form of list corruption. With
configASSERT()undefined there is no behavioural or size change.The assert is placed after the local declarations and
traceENTER_vListInsert(), in keeping with the C90 / MISRA style used in the kernel.Testing
list.cwith gcc (-std=c99 -Wall -Wextra -Wdeclaration-after-statement).