From 9162e6842354d4022f7692536a888d10bee8fede Mon Sep 17 00:00:00 2001 From: Aaron Rossetto Date: Fri, 20 May 2022 07:26:41 -0500 Subject: 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. --- host/lib/rfnoc/replay_block_control.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'host/lib') 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, -- cgit v1.2.3