summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcus Müller <marcus.mueller@ettus.com>2018-07-08 14:55:04 +0200
committerMarcus Müller <marcus@hostalia.de>2018-07-09 20:35:38 +0200
commit35c2b32d0c4dad1dc69cbb77293aa6ff515c76f5 (patch)
tree1e0ebebbfa3c31e9d552e0a6365aa0c6550fb60e
parent3691c57bd6c25ad93ef22d32ebdbd61a5d9727c4 (diff)
Fix vector out of bound accesses
Unless most of the other #1776-related fixes, this actually was an effect of reading from unitialized memory. I'm surprised this worked as intended! Needs content-wise review from @jdemel!
-rw-r--r--gr-fec/lib/polar_common.cc7
1 files changed, 3 insertions, 4 deletions
diff --git a/gr-fec/lib/polar_common.cc b/gr-fec/lib/polar_common.cc
index c04ec5a15c..fcb34c2d35 100644
--- a/gr-fec/lib/polar_common.cc
+++ b/gr-fec/lib/polar_common.cc
@@ -108,14 +108,13 @@ namespace gr {
d_volk_temp = (unsigned char*) volk_malloc(sizeof(unsigned char) * block_size(), volk_get_alignment());
d_volk_frozen_bit_mask = (unsigned char*) volk_malloc(sizeof(unsigned char) * block_size(), volk_get_alignment());
d_volk_frozen_bits = (unsigned char*) volk_malloc(sizeof(unsigned char) * nfrozen, volk_get_alignment());
- for(int i = 0; i < nfrozen; i++){
- d_volk_frozen_bits[i] = d_frozen_bit_values[i];
- }
+ std::copy(d_frozen_bit_values.begin(), d_frozen_bit_values.end(), d_volk_frozen_bits);
+ std::fill(d_volk_frozen_bits + d_frozen_bit_values.size(), d_volk_frozen_bits + nfrozen, 0);
int nfbit = 0;
for(int i = 0; i < block_size(); i++){
unsigned char m = 0x00;
- if(d_frozen_bit_positions[nfbit] == i){
+ if(nfbit < d_frozen_bit_positions.size() && d_frozen_bit_positions[nfbit] == i){
m = 0xFF;
nfbit++;
}