aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2017-01-28 17:07:43 +0100
committerMatthias P. Braendli <matthias.braendli@mpb.li>2017-01-28 17:07:43 +0100
commita82b7af30885175c66691a4e8b95bff9b11514db (patch)
treecce7dd6f3e411ded8474d2642ccc2db8a9d00ba0 /src
parent000796dc3d909f179fb6586fae7e9ce986440576 (diff)
downloaddabmux-a82b7af30885175c66691a4e8b95bff9b11514db.tar.gz
dabmux-a82b7af30885175c66691a4e8b95bff9b11514db.tar.bz2
dabmux-a82b7af30885175c66691a4e8b95bff9b11514db.zip
Fix vector index bug in EDI PFT layer
Diffstat (limited to 'src')
-rw-r--r--src/dabOutput/edi/PFT.cpp16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/dabOutput/edi/PFT.cpp b/src/dabOutput/edi/PFT.cpp
index 511a6ae..4bce1f1 100644
--- a/src/dabOutput/edi/PFT.cpp
+++ b/src/dabOutput/edi/PFT.cpp
@@ -158,11 +158,12 @@ vector< vector<uint8_t> > PFT::ProtectAndFragment(AFPacket af_packet)
for (size_t i = 0; i < num_fragments; i++) {
fragments[i].resize(fragment_size);
for (size_t j = 0; j < fragment_size; j++) {
- if (j*num_fragments + i > rs_block.size()) {
- fragments[i][j] = 0;
+ const size_t ix = j*num_fragments + i;
+ if (ix < rs_block.size()) {
+ fragments[i][j] = rs_block[ix];
}
else {
- fragments[i][j] = rs_block[j*num_fragments + i];
+ fragments[i][j] = 0;
}
}
}
@@ -183,14 +184,15 @@ vector< vector<uint8_t> > PFT::ProtectAndFragment(AFPacket af_packet)
vector< vector<uint8_t> > fragments(num_fragments);
for (size_t i = 0; i < num_fragments; i++) {
- //fragments[i].reserve(fragment_size);
+ fragments[i].reserve(fragment_size);
for (size_t j = 0; j < fragment_size; j++) {
- if (i*fragment_size + j > af_packet.size()) {
- break;
+ const size_t ix = i*fragment_size + j;
+ if (ix < af_packet.size()) {
+ fragments[i].push_back(af_packet.at(ix));
}
else {
- fragments[i].push_back(af_packet[i*fragment_size + j]);
+ break;
}
}
}