Skip to content

Commit

Permalink
Fix PSI extraction
Browse files Browse the repository at this point in the history
  • Loading branch information
xtne6f committed May 21, 2022
1 parent d0aff40 commit bf0ca4f
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,8 @@ int extract_psi(PSI *psi, const uint8_t *payload, int payload_size, int unit_sta
return 1;
}
}
if (copy_size > 0 && copy_pos < payload_size) {
if (copy_size > static_cast<int>(sizeof(psi->data)) - psi->data_count) {
copy_size = static_cast<int>(sizeof(psi->data)) - psi->data_count;
}
if (copy_size > 0 && copy_pos + copy_size <= payload_size) {
copy_size = std::min(copy_size, static_cast<int>(sizeof(psi->data)) - psi->data_count);
std::copy(payload + copy_pos, payload + copy_pos + copy_size, psi->data + psi->data_count);
psi->data_count += copy_size;
}
Expand Down

0 comments on commit bf0ca4f

Please sign in to comment.