diff options
author | Aaron Rossetto <aaron.rossetto@ni.com> | 2022-05-20 07:26:41 -0500 |
---|---|---|
committer | Aaron Rossetto <aaron.rossetto@ni.com> | 2022-06-10 13:24:05 -0500 |
commit | 9162e6842354d4022f7692536a888d10bee8fede (patch) | |
tree | f3af06b2d5aa375d20bd4a9374d24b4d09fc5b9f /host/lib/rfnoc | |
parent | f9327a4a400269769329512ac145a4b845b480e6 (diff) | |
download | uhd-9162e6842354d4022f7692536a888d10bee8fede.tar.gz uhd-9162e6842354d4022f7692536a888d10bee8fede.tar.bz2 uhd-9162e6842354d4022f7692536a888d10bee8fede.zip |
rfnoc: Fix vector use in replay_block_control_impl
This commit fixes an issue in `replay_block_control_impl` with the
initialization of the `_cmd_fifo_spaces` vector member variable.
`std::vector<>::reserve()` only allocates memory for the vector items;
it does not resize the vector (i.e., instantiating an `std::vector<>`
and then calling `reserve()` leaves it with a size of 0). Attempting to
index a zero-sized vector causes some C++ debug mode runtimes to throw
an index out-of-range exception. The commit instantiates the vector
using the constructor variant that allocates memory sufficient for the
entries and default initializes them so that it can be indexed without
issue.
Diffstat (limited to 'host/lib/rfnoc')
-rw-r--r-- | host/lib/rfnoc/replay_block_control.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/host/lib/rfnoc/replay_block_control.cpp b/host/lib/rfnoc/replay_block_control.cpp index f7497c657..565108420 100644 --- a/host/lib/rfnoc/replay_block_control.cpp +++ b/host/lib/rfnoc/replay_block_control.cpp @@ -87,7 +87,8 @@ public: _word_size( uint16_t((_replay_reg_iface.peek32(REG_MEM_SIZE_ADDR) >> 16) & 0xFFFF) / 8), _mem_size( - uint64_t(1ULL << (_replay_reg_iface.peek32(REG_MEM_SIZE_ADDR) & 0xFFFF))) + uint64_t(1ULL << (_replay_reg_iface.peek32(REG_MEM_SIZE_ADDR) & 0xFFFF))), + _cmd_fifo_spaces(_num_output_ports) { if (get_num_input_ports() != get_num_output_ports()) { throw uhd::assertion_error( @@ -175,7 +176,6 @@ public: _play_size.reserve(_num_output_ports); _packet_size.reserve(_num_output_ports); _atomic_item_size_out.reserve(_num_output_ports); - _cmd_fifo_spaces.reserve(_num_output_ports); for (size_t port = 0; port < _num_output_ports; port++) { _register_output_props(port); _replay_reg_iface.poke32(REG_PLAY_ITEM_SIZE_ADDR, |