Skip to content

Commit

Permalink
Merge pull request #1602 from garrettgu10/ggu/unchecked-malloc
Browse files Browse the repository at this point in the history
Fix unchecked malloc
  • Loading branch information
garrettgu10 authored Feb 6, 2024
2 parents 99b1fd2 + 4cf5efa commit 18eea99
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/workerd/io/worker.c++
Original file line number Diff line number Diff line change
Expand Up @@ -720,11 +720,8 @@ static void stopProfiling(jsg::Lock& js,
}

auto hitLineCount = allNodes[i]->GetHitLineCount();
v8::CpuProfileNode::LineTick* lineBuffer =
(v8::CpuProfileNode::LineTick*)malloc(
hitLineCount * sizeof(v8::CpuProfileNode::LineTick));
KJ_DEFER(free(lineBuffer));
allNodes[i]->GetLineTicks(lineBuffer, hitLineCount);
auto lineBuffer = kj::heapArray<v8::CpuProfileNode::LineTick>(hitLineCount);
allNodes[i]->GetLineTicks(lineBuffer.begin(), lineBuffer.size());

auto positionTicks = nodeBuilder.initPositionTicks(hitLineCount);
for (uint j=0; j < hitLineCount; j++) {
Expand Down

0 comments on commit 18eea99

Please sign in to comment.