[dlmalloc] Fix -Wnull-pointer-arithmetic

Arithmetic on a NULL pointer is undefined behaviour and could be used by
the compiler to optimize out the arithmetic. Use the integer expansion of
chunk2mem(0) instead to silence this warning:
`arithmetic on a null pointer treated as a cast from integer to pointer is a GNU extension [-Wnull-pointer-arithmetic]`
This commit is contained in:
Alex Richardson
2021-12-09 14:37:45 +00:00
committed by Travis Geiselbrecht
parent a1eb850079
commit 7b12b201fd

View File

@@ -2784,7 +2784,7 @@ static int has_segment_link(mstate m, msegmentptr ss) {
noncontiguous segments are added.
*/
#define TOP_FOOT_SIZE\
(align_offset(chunk2mem(0))+pad_request(sizeof(struct malloc_segment))+MIN_CHUNK_SIZE)
(align_offset(/*chunk2mem(0)*/TWO_SIZE_T_SIZES)+pad_request(sizeof(struct malloc_segment))+MIN_CHUNK_SIZE)
/* ------------------------------- Hooks -------------------------------- */