Skip to content

Commit 00bf88e

Browse files
committed
fix alloc sanity
1 parent e49efaa commit 00bf88e

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

‎src/iso_alloc.c‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1126,7 +1126,7 @@ INTERNAL_HIDDEN ASSUME_ALIGNED void *_iso_alloc(iso_alloc_zone_t *zone, size_t s
11261126

11271127
#if ALLOC_SANITY
11281128
/* We only sample if a zone was not directly passed */
1129-
if(zone != NULL) {
1129+
if(zone == NULL) {
11301130
if(size < g_page_size && _sane_sampled < MAX_SANE_SAMPLES) {
11311131
/* If we chose to sample this allocation then
11321132
* _iso_alloc_sample will call UNLOCK_ROOT() */
@@ -1511,6 +1511,17 @@ INTERNAL_HIDDEN void _iso_free_from_zone(void *p, iso_alloc_zone_t *zone, bool p
15111511
return;
15121512
}
15131513

1514+
#if ALLOC_SANITY
1515+
/* A sampled chunk lives in its own guarded page and
1516+
* not in any zone, so this must run before we validate
1517+
* p against the zones user pages */
1518+
int32_t r = _iso_alloc_free_sane_sample(p);
1519+
1520+
if(r == OK) {
1521+
return;
1522+
}
1523+
#endif
1524+
15141525
#if MEMORY_TAGGING
15151526
/* Its possible that we were passed a tagged pointer */
15161527
if(UNLIKELY(zone->tagged == true && ((uintptr_t) p & IS_TAGGED_PTR_MASK) != 0)) {

0 commit comments

Comments
 (0)