@@ -63,6 +63,13 @@ struct chunk_begin {
6363
6464} __attribute__((packed ));
6565
66+ struct chunk_struct {
67+ struct chunk_begin begin ;
68+ char redzone [REDZONE_SIZE ];
69+ size_t prev_size_padding ;
70+
71+ } __attribute__((packed ));
72+
6673#ifdef USE_LIBC_ALLOC
6774
6875void * (* __lq_libc_memalign )(size_t , size_t );
@@ -170,14 +177,14 @@ void *__libqasan_malloc(size_t size) {
170177
171178 struct chunk_begin * p = backend_memalign (
172179 ALLOC_ALIGN_SIZE ,
173- sizeof (struct chunk_begin ) + qasan_align_up (size , ALLOC_ALIGN_SIZE ));
180+ sizeof (struct chunk_struct ) + qasan_align_up (size , ALLOC_ALIGN_SIZE ));
174181
175182 QASAN_SWAP (state );
176183
177184 if (!p ) return NULL ;
178185
179186 QASAN_UNPOISON (
180- p , sizeof (struct chunk_begin ) + qasan_align_up (size , ALLOC_ALIGN_SIZE ));
187+ p , sizeof (struct chunk_struct ) + qasan_align_up (size , ALLOC_ALIGN_SIZE ));
181188
182189 p -> requested_size = size ;
183190 p -> aligned_orig = NULL ;
@@ -274,13 +281,13 @@ int __libqasan_posix_memalign(void **ptr, size_t align, size_t len) {
274281
275282 char * orig = backend_memalign (
276283 ALLOC_ALIGN_SIZE ,
277- sizeof (struct chunk_begin ) + qasan_align_up (size , ALLOC_ALIGN_SIZE ));
284+ sizeof (struct chunk_struct ) + qasan_align_up (size , ALLOC_ALIGN_SIZE ));
278285
279286 QASAN_SWAP (state );
280287
281288 if (!orig ) return ENOMEM ;
282289
283- QASAN_UNPOISON (orig , sizeof (struct chunk_begin ) +
290+ QASAN_UNPOISON (orig , sizeof (struct chunk_struct ) +
284291 qasan_align_up (size , ALLOC_ALIGN_SIZE ));
285292
286293 char * data = orig + sizeof (struct chunk_begin );
0 commit comments