mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-14 14:46:12 -04:00
Fix heap-use-after-free issue in fake timer
PiperOrigin-RevId: 530644090
This commit is contained in:
committed by
Copybara-Service
parent
332da370a4
commit
ebab912fb6
@@ -65,7 +65,9 @@ void FakeTimer::ClockUpdated() {
|
||||
|
||||
if (duration >= delay_ && fired_count_ == 0) {
|
||||
++fired_count_;
|
||||
callback_();
|
||||
if (callback_ != nullptr) {
|
||||
callback_();
|
||||
}
|
||||
}
|
||||
|
||||
if (period_ == 0 || duration < delay_ ||
|
||||
@@ -77,7 +79,9 @@ void FakeTimer::ClockUpdated() {
|
||||
int should_fire_count = count - fired_count_ + 1;
|
||||
for (int i = 0; i < should_fire_count; ++i) {
|
||||
++fired_count_;
|
||||
callback_();
|
||||
if (callback_ != nullptr) {
|
||||
callback_();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user