Skip to content

Commit

Permalink
deps: avoid overflow when calculating timeDeltas
Browse files Browse the repository at this point in the history
PR-URL: #229
Reviewed-by: Juan José Arboleda <[email protected]>
  • Loading branch information
santigimeno authored and juanarbol committed Nov 22, 2024
1 parent 9a844ef commit a06d151
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions deps/v8/src/profiler/profile-generator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -872,12 +872,12 @@ void CpuProfileJSONSerializer::SerializeNodes() {

void CpuProfileJSONSerializer::SerializeTimeDeltas() {
int count = profile_->samples_count();
uint64_t lastTime = profile_->start_time().since_origin().InMicroseconds();
base::TimeTicks lastTimestamp = profile_->start_time();
for (int i = 0; i < count; i++) {
uint64_t ts = profile_->sample(i).timestamp.since_origin().InMicroseconds();
writer_->AddNumber(static_cast<int>(ts - lastTime));
writer_->AddNumber(static_cast<int>(
(profile_->sample(i).timestamp - lastTimestamp).InMicroseconds()));
if (i != (count - 1)) writer_->AddString(",");
lastTime = ts;
lastTimestamp = profile_->sample(i).timestamp;
}
}

Expand Down

0 comments on commit a06d151

Please sign in to comment.