Commit a35da11d authored by imcheng@chromium.org's avatar imcheng@chromium.org

[Cast] Fix log_deserializer BasePacketEvent merge bug.

The bug is that if we are merging BasePacketEvent A into B, and A had
a valid packet size but B did not (i.e. because it only has receiver
events and therefore no packet size) then the merged result would take
on the packet size of B which is invalid.

The fix is to take the max of the sizes of A and B and set it on the
merged result.

Review URL: https://codereview.chromium.org/331383006

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@278421 0039d316-1c4b-4281-b951-d872f2087c98
parent d11ebebb
......@@ -35,7 +35,12 @@ void MergePacketEvent(const AggregatedPacketEvent& from,
for (int j = 0; j < to->base_packet_event_size(); j++) {
BasePacketEvent* to_base_event = to->mutable_base_packet_event(j);
if (from_base_event.packet_id() == to_base_event->packet_id()) {
int packet_size = std::max(
from_base_event.size(), to_base_event->size());
// Need special merge logic here because we need to prevent a valid
// packet size (> 0) from being overwritten with an invalid one (= 0).
to_base_event->MergeFrom(from_base_event);
to_base_event->set_size(packet_size);
merged = true;
break;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment