Skip to content
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

Refine heap_5 heap protector #1146

Merged
merged 2 commits into from
Sep 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions portable/MemMang/heap_5.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,19 @@
* heapVALIDATE_BLOCK_POINTER assert. */
#define heapPROTECT_BLOCK_POINTER( pxBlock ) ( ( BlockLink_t * ) ( ( ( portPOINTER_SIZE_TYPE ) ( pxBlock ) ) ^ xHeapCanary ) )

/* Assert that a heap block pointer is within the heap bounds. */
#define heapVALIDATE_BLOCK_POINTER( pxBlock ) \
configASSERT( ( pucHeapHighAddress != NULL ) && \
( pucHeapLowAddress != NULL ) && \
( ( uint8_t * ) ( pxBlock ) >= pucHeapLowAddress ) && \
( ( uint8_t * ) ( pxBlock ) < pucHeapHighAddress ) )
/* Assert that a heap block pointer is within the heap bounds.
* Setting configVALIDATE_HEAP_BLOCK_POINTER to 1 enables customized heap block pointers
* protection on heap_5. */
#ifndef configVALIDATE_HEAP_BLOCK_POINTER
#define heapVALIDATE_BLOCK_POINTER( pxBlock ) \
configASSERT( ( pucHeapHighAddress != NULL ) && \
( pucHeapLowAddress != NULL ) && \
( ( uint8_t * ) ( pxBlock ) >= pucHeapLowAddress ) && \
( ( uint8_t * ) ( pxBlock ) < pucHeapHighAddress ) )
#else /* ifndef configVALIDATE_HEAP_BLOCK_POINTER */
#define heapVALIDATE_BLOCK_POINTER( pxBlock ) \
configVALIDATE_HEAP_BLOCK_POINTER( pxBlock )
#endif /* configVALIDATE_HEAP_BLOCK_POINTER */

#else /* if ( configENABLE_HEAP_PROTECTOR == 1 ) */

Expand Down
Loading