Skip to content

Commit a66dc46

Browse files
authored
[scudo] allocation_ring_buffer_size <= 0 disables buffer (#71791)
Prevent a null pointer exception for allocation_ring_buffer_size < 0.
1 parent e35b606 commit a66dc46

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

compiler-rt/lib/scudo/standalone/combined.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -886,7 +886,7 @@ class Allocator {
886886

887887
void setTrackAllocationStacks(bool Track) {
888888
initThreadMaybe();
889-
if (getFlags()->allocation_ring_buffer_size == 0) {
889+
if (getFlags()->allocation_ring_buffer_size <= 0) {
890890
DCHECK(!Primary.Options.load().get(OptionBit::TrackAllocationStacks));
891891
return;
892892
}
@@ -1490,10 +1490,10 @@ class Allocator {
14901490
}
14911491

14921492
void mapAndInitializeRingBuffer() {
1493+
if (getFlags()->allocation_ring_buffer_size <= 0)
1494+
return;
14931495
u32 AllocationRingBufferSize =
14941496
static_cast<u32>(getFlags()->allocation_ring_buffer_size);
1495-
if (AllocationRingBufferSize < 1)
1496-
return;
14971497
MemMapT MemMap;
14981498
MemMap.map(
14991499
/*Addr=*/0U,

compiler-rt/lib/scudo/standalone/flags.inc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,5 @@ SCUDO_FLAG(int, release_to_os_interval_ms, SCUDO_ANDROID ? INT32_MIN : 5000,
4747
"memory to the OS. Negative values disable the feature.")
4848

4949
SCUDO_FLAG(int, allocation_ring_buffer_size, 32768,
50-
"Entries to keep in the allocation ring buffer for scudo.")
50+
"Entries to keep in the allocation ring buffer for scudo. "
51+
"Values less or equal to zero disable the buffer.")

0 commit comments

Comments
 (0)