Skip to content

Commit

Permalink
[wpiutil] DataLog: Fix UB in AppendImpl (wpilibsuite#6088)
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterJohnson authored Dec 23, 2023
1 parent ab309e3 commit c29e8c6
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions wpiutil/src/main/native/cpp/DataLog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -743,8 +743,10 @@ void DataLog::AppendImpl(std::span<const uint8_t> data) {
std::memcpy(buf, data.data(), kBlockSize);
data = data.subspan(kBlockSize);
}
uint8_t* buf = Reserve(data.size());
std::memcpy(buf, data.data(), data.size());
if (!data.empty()) {
uint8_t* buf = Reserve(data.size());
std::memcpy(buf, data.data(), data.size());
}
}

void DataLog::AppendStringImpl(std::string_view str) {
Expand Down

0 comments on commit c29e8c6

Please sign in to comment.