Skip to content

Commit 16ae094

Browse files
committed
Update block validate macro in heap_5
* Not validate block pointer when configENABLE_HEAP_PROTECTOR is not set to 1
1 parent af2904b commit 16ae094

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

portable/MemMang/heap_5.c

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -143,30 +143,32 @@ typedef struct A_BLOCK_LINK
143143
/* Canary value for protecting internal heap pointers. */
144144
PRIVILEGED_DATA static portPOINTER_SIZE_TYPE xHeapCanary;
145145

146-
147146
/* Macro to load/store BlockLink_t pointers to memory. By XORing the
148147
* pointers with a random canary value, heap overflows will result
149148
* in randomly unpredictable pointer values which will be caught by
150149
* heapVALIDATE_BLOCK_POINTER assert. */
151150
#define heapPROTECT_BLOCK_POINTER( pxBlock ) ( ( BlockLink_t * ) ( ( ( portPOINTER_SIZE_TYPE ) ( pxBlock ) ) ^ xHeapCanary ) )
152151

153-
#else /* if ( configENABLE_HEAP_PROTECTOR == 1 ) */
154-
155-
#define heapPROTECT_BLOCK_POINTER( pxBlock ) ( pxBlock )
156-
157-
#endif /* configENABLE_HEAP_PROTECTOR */
158-
159-
/* Highest and lowest heap addresses used for heap block bounds checking. */
160-
PRIVILEGED_DATA static uint8_t * pucHeapHighAddress = NULL;
161-
PRIVILEGED_DATA static uint8_t * pucHeapLowAddress = NULL;
162-
163152
/* Assert that a heap block pointer is within the heap bounds. */
164-
#define heapVALIDATE_BLOCK_POINTER( pxBlock ) \
153+
#define heapVALIDATE_BLOCK_POINTER( pxBlock ) \
165154
configASSERT( ( pucHeapHighAddress != NULL ) && \
166155
( pucHeapLowAddress != NULL ) && \
167156
( ( uint8_t * ) ( pxBlock ) >= pucHeapLowAddress ) && \
168157
( ( uint8_t * ) ( pxBlock ) < pucHeapHighAddress ) )
169158

159+
/* Highest and lowest heap addresses used for heap block bounds checking. */
160+
PRIVILEGED_DATA static uint8_t * pucHeapHighAddress = NULL;
161+
PRIVILEGED_DATA static uint8_t * pucHeapLowAddress = NULL;
162+
163+
#else /* if ( configENABLE_HEAP_PROTECTOR == 1 ) */
164+
165+
#define heapPROTECT_BLOCK_POINTER( pxBlock ) ( pxBlock )
166+
167+
#define heapVALIDATE_BLOCK_POINTER( pxBlock ) ( pxBlock )
168+
169+
#endif /* configENABLE_HEAP_PROTECTOR */
170+
171+
170172
/*-----------------------------------------------------------*/
171173

172174
/*

0 commit comments

Comments
 (0)