From a82b7af30885175c66691a4e8b95bff9b11514db Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Sat, 28 Jan 2017 17:07:43 +0100 Subject: Fix vector index bug in EDI PFT layer --- src/dabOutput/edi/PFT.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'src/dabOutput') 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 > 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 > PFT::ProtectAndFragment(AFPacket af_packet) vector< vector > 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; } } } -- cgit v1.2.3