Skip to content

Commit

Permalink
Fix asan error about possible division by zero
Browse files Browse the repository at this point in the history
  • Loading branch information
jbachorik committed Aug 4, 2024
1 parent ff656ef commit bf384e4
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion ddprof-lib/src/main/cpp/flightRecorder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1280,7 +1280,8 @@ void Recording::recordHeapLiveObject(Buffer* buf, int tid, u32 call_trace_id, Ob
buf->putVar32(event->_id);
buf->putVar64(event->_age);
buf->putVar64(event->_alloc._size);
buf->putFloat(((event->_alloc._weight * event->_alloc._size) + event->_skipped) / event->_alloc._size);
// the _alloc._size is 0 only when running in the lightweight mode, only tracking surviving generations
buf->putFloat(event->_alloc._size > 0 ? ((event->_alloc._weight * event->_alloc._size) + event->_skipped) / event->_alloc._size : 0);
writeContext(buf, event->_ctx);
writeEventSizePrefix(buf, start);
flushIfNeeded(buf);
Expand Down

0 comments on commit bf384e4

Please sign in to comment.