Fix heap-use-after-free issue in fake timer

PiperOrigin-RevId: 530644090
This commit is contained in:
Nick Bourdakos
2023-05-09 10:15:09 -07:00
committed by Copybara-Service
parent 332da370a4
commit ebab912fb6
+6 -2
View File
@@ -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_();
}
}
}