Fix pac_mapped stats inflation on allocation failure

newly_mapped_size was set unconditionally in the ecache_alloc_grow
fallback path, even when the allocation returned NULL. This inflated
pac_mapped stats without a corresponding deallocation to correct them.

Guard the assignment with an edata != NULL check, matching the pattern
used in the batched allocation path above it.
This commit is contained in:
Slobodan Predolac 2026-03-27 10:03:06 -07:00
parent c2d57040f0
commit 3a8bee81f1

View file

@ -198,7 +198,9 @@ pac_alloc_real(tsdn_t *tsdn, pac_t *pac, ehooks_t *ehooks, size_t size,
edata = ecache_alloc_grow(tsdn, pac, ehooks,
&pac->ecache_retained, NULL, size, alignment, zero,
guarded);
newly_mapped_size = size;
if (edata != NULL) {
newly_mapped_size = size;
}
}
if (config_stats && newly_mapped_size != 0) {