Skip to content

Commit

Permalink
Merge "Ignore log files with corrupted headers too"
Browse files Browse the repository at this point in the history
  • Loading branch information
AustinSchuh authored and frc971-automation committed Dec 12, 2020
2 parents 89597d5 + e09beb1 commit 61b9e3f
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions aos/events/logging/logfile_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,11 @@ std::optional<SizePrefixedFlatbufferVector<LogFileHeader>> ReadHeader(
ResizeableBuffer data;
data.resize(config_data.size());
memcpy(data.data(), config_data.begin(), data.size());
return SizePrefixedFlatbufferVector<LogFileHeader>(std::move(data));
SizePrefixedFlatbufferVector<LogFileHeader> result(std::move(data));
if (!result.Verify()) {
return std::nullopt;
}
return result;
}

std::optional<SizePrefixedFlatbufferVector<MessageHeader>> ReadNthMessage(
Expand All @@ -382,7 +386,11 @@ std::optional<SizePrefixedFlatbufferVector<MessageHeader>> ReadNthMessage(
ResizeableBuffer data;
data.resize(data_span.size());
memcpy(data.data(), data_span.begin(), data.size());
return SizePrefixedFlatbufferVector<MessageHeader>(std::move(data));
SizePrefixedFlatbufferVector<MessageHeader> result(std::move(data));
if (!result.Verify()) {
return std::nullopt;
}
return result;
}

MessageReader::MessageReader(std::string_view filename)
Expand Down

0 comments on commit 61b9e3f

Please sign in to comment.