diff options
author | Thomas Habets <habets@google.com> | 2021-03-16 14:25:00 +0000 |
---|---|---|
committer | mormj <34754695+mormj@users.noreply.github.com> | 2021-03-16 15:14:39 -0400 |
commit | f4fc23b362252d23d3d11c3f7f5bd21f5292c271 (patch) | |
tree | b84d3a8fffd4a13181e8935ade133693f9cb55d7 | |
parent | cb9fe59e3abe58e97f1408f1d57885aef22814fe (diff) |
qtgui: Fix segfaulting overflow
Problem introduced in
4b7006db76b570e4d916e263301333d2f4d2a2df. `d_cbuffers` and `d_buffers`
are not the same size.
It appears to be the only instance of this mistake in that commit.
Fixes: #4396
Signed-off-by: Thomas Habets <habets@google.com>
-rw-r--r-- | gr-qtgui/lib/time_sink_c_impl.cc | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/gr-qtgui/lib/time_sink_c_impl.cc b/gr-qtgui/lib/time_sink_c_impl.cc index 05c110b33a..e557f2b4ee 100644 --- a/gr-qtgui/lib/time_sink_c_impl.cc +++ b/gr-qtgui/lib/time_sink_c_impl.cc @@ -56,10 +56,6 @@ time_sink_c_impl::time_sink_c_impl(int size, if (nconnections > 12) throw std::runtime_error("time_sink_c only supports up to 12 inputs"); - // setup PDU handling input port - message_port_register_in(pmt::mp("in")); - set_msg_handler(pmt::mp("in"), [this](pmt::pmt_t msg) { this->handle_pdus(msg); }); - // +2 for the PDU message buffers for (unsigned int n = 0; n < d_nconnections + 2; n++) { d_buffers.emplace_back(d_buffer_size); @@ -70,6 +66,10 @@ time_sink_c_impl::time_sink_c_impl(int size, d_cbuffers.emplace_back(d_buffer_size); } + // setup PDU handling input port + message_port_register_in(pmt::mp("in")); + set_msg_handler(pmt::mp("in"), [this](pmt::pmt_t msg) { this->handle_pdus(msg); }); + // Set alignment properties for VOLK const int alignment_multiple = volk_get_alignment() / sizeof(gr_complex); set_alignment(std::max(1, alignment_multiple)); @@ -277,11 +277,14 @@ void time_sink_c_impl::set_nsamps(const int newsize) d_buffer_size = 2 * d_size; // Resize buffers and replace data - for (unsigned int n = 0; n < d_nconnections + 2; n++) { - d_buffers[n].clear(); - d_buffers[n].resize(d_buffer_size); - d_cbuffers[n].clear(); - d_cbuffers[n].resize(d_buffer_size); + for (auto& buf : d_buffers) { + buf.clear(); + buf.resize(d_buffer_size); + } + + for (auto& cbuf : d_cbuffers) { + cbuf.clear(); + cbuf.resize(d_buffer_size); } // If delay was set beyond the new boundary, pull it back. |