Skip to content

Commit

Permalink
addressing comment
Browse files Browse the repository at this point in the history
  • Loading branch information
chunhtai committed Nov 14, 2019
1 parent 749f7b4 commit 06e42a9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions lib/ui/window/pointer_data_packet_converter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ std::unique_ptr<PointerDataPacket> PointerDataPacketConverter::Convert(
// Converts each pointer data in the buffer and stores it in the
// converted_pointers.
for (size_t i = 0; i < buffer_length / kBytesPerPointerData; i++) {
PointerData pointer_data =
*(reinterpret_cast<PointerData*>(&buffer[i * kBytesPerPointerData]));
PointerData pointer_data;
memcpy(&pointer_data, &buffer[i * kBytesPerPointerData],
sizeof(PointerData));
ConvertPointerData(pointer_data, converted_pointers);
}

Expand Down
5 changes: 3 additions & 2 deletions lib/ui/window/pointer_data_packet_converter_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,9 @@ void UnpackPointerPacket(std::vector<PointerData>& output,
size_t buffer_length = buffer.size();

for (size_t i = 0; i < buffer_length / kBytesPerPointerData; i++) {
PointerData pointer_data =
*(reinterpret_cast<PointerData*>(&buffer[i * kBytesPerPointerData]));
PointerData pointer_data;
memcpy(&pointer_data, &buffer[i * kBytesPerPointerData],
sizeof(PointerData));
output.push_back(pointer_data);
}
packet.reset();
Expand Down

0 comments on commit 06e42a9

Please sign in to comment.