Skip to content

Commit

Permalink
Fixed hasardous cast in streamer example
Browse files Browse the repository at this point in the history
  • Loading branch information
paullouisageneau committed Aug 12, 2023
1 parent 059d06e commit 9cfb6dd
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions examples/streamer/fileparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,9 @@ void FileParser::loadNextSample() {
return;
}

vector<uint8_t> fileContents((std::istreambuf_iterator<char>(source)), std::istreambuf_iterator<char>());
sample = *reinterpret_cast<vector<byte> *>(&fileContents);
vector<char> contents((std::istreambuf_iterator<char>(source)), std::istreambuf_iterator<char>());
auto *b = reinterpret_cast<const std::byte*>(contents.data());
sample.assign(b, b + contents.size());
sampleTime_us += sampleDuration_us;
}

Expand Down

0 comments on commit 9cfb6dd

Please sign in to comment.