Skip to content

Commit

Permalink
CANParser: fix can data size issue (#799)
Browse files Browse the repository at this point in the history
fix can data size issues

Co-authored-by: Shane Smiskol <[email protected]>
  • Loading branch information
deanlee and sshane committed Jun 7, 2024
1 parent f58bc33 commit 0ccfa9c
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions can/parser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,9 @@ void CANParser::UpdateCans(uint64_t nanos, const capnp::List<cereal::CanData>::R
// DEBUG("got message with unexpected length: expected %d, got %zu for %d", state_it->second.size, dat.size(), cmsg.getAddress());
// continue;
//}

std::vector<uint8_t> data(dat.size(), 0);
// make sure the data_size if not less than state_it->second.size.
size_t data_size = std::max<size_t>(dat.size(), state_it->second.size);
std::vector<uint8_t> data(data_size, 0);
memcpy(data.data(), dat.begin(), dat.size());
state_it->second.parse(nanos, data);
}
Expand Down

0 comments on commit 0ccfa9c

Please sign in to comment.