Skip to content

Commit 4c69001

Browse files
authored
Ensure SYSTEM_STATS_INCREMENT only on successful Timer allocation in SystemTimer.h (#36690)
* Fix: Ensure SYSTEM_STATS_INCREMENT only on successful Timer allocation * Update SystemTimer.h
1 parent e7b0989 commit 4c69001

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/system/SystemTimer.h

+5-1
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,11 @@ class TimerPool
204204
Timer * Create(Layer & systemLayer, System::Clock::Timestamp awakenTime, TimerCompleteCallback onComplete, void * appState)
205205
{
206206
Timer * timer = mTimerPool.CreateObject(systemLayer, awakenTime, onComplete, appState);
207-
SYSTEM_STATS_INCREMENT(Stats::kSystemLayer_NumTimers);
207+
if (timer != nullptr)
208+
{
209+
SYSTEM_STATS_INCREMENT(Stats::kSystemLayer_NumTimers);
210+
}
211+
208212
return timer;
209213
}
210214

0 commit comments

Comments
 (0)