aboutsummaryrefslogtreecommitdiffstats
path: root/gr-qtgui
diff options
context:
space:
mode:
authorThomas Habets <habets@google.com>2021-03-16 14:25:00 +0000
committermormj <34754695+mormj@users.noreply.github.com>2021-03-16 15:14:39 -0400
commitf4fc23b362252d23d3d11c3f7f5bd21f5292c271 (patch)
treeb84d3a8fffd4a13181e8935ade133693f9cb55d7 /gr-qtgui
parentuhd: Fix Qt apps (XInitThreads call order, terminate handling) (diff)
downloadgnuradio-f4fc23b362252d23d3d11c3f7f5bd21f5292c271.tar.xz
gnuradio-f4fc23b362252d23d3d11c3f7f5bd21f5292c271.zip
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>
Diffstat (limited to 'gr-qtgui')
-rw-r--r--gr-qtgui/lib/time_sink_c_impl.cc21
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 05c110b33..e557f2b4e 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.