From 84027120ccaeb232618b01e717b97bd9adcc4588 Mon Sep 17 00:00:00 2001 From: Matthew Smith Date: Wed, 23 Oct 2024 14:54:00 +0200 Subject: [PATCH] Fix OSC observer heap buffer-overflow --- libs/surfaces/osc/osc_cue_observer.cc | 6 ++---- libs/surfaces/osc/osc_cue_observer.h | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/libs/surfaces/osc/osc_cue_observer.cc b/libs/surfaces/osc/osc_cue_observer.cc index 8ca17d27a3..0774f3c70f 100644 --- a/libs/surfaces/osc/osc_cue_observer.cc +++ b/libs/surfaces/osc/osc_cue_observer.cc @@ -94,7 +94,7 @@ OSCCueObserver::refresh_strip (std::shared_ptr new_strip, Sor _strip->mute_control()->Changed.connect (strip_connections, MISSING_INVALIDATOR, std::bind (&OSCCueObserver::send_change_message, this, X_("/cue/mute"), 0, std::weak_ptr(_strip->mute_control())), OSC::instance()); send_change_message (X_("/cue/mute"), 0, _strip->mute_control()); - gain_timeout.push_back (0); + gain_timeout[0] = 0; _last_gain[0] = -1; // unused _strip->gain_control()->Changed.connect (strip_connections, MISSING_INVALIDATOR, std::bind (&OSCCueObserver::send_gain_message, this, 0, std::weak_ptr(_strip->gain_control()), false), OSC::instance()); send_gain_message (0, _strip->gain_control(), true); @@ -162,7 +162,7 @@ OSCCueObserver::send_init() if (send->gain_control()) { - gain_timeout.push_back (0); + gain_timeout[i + 1] = 0; _last_gain[i + 1] = -1.0; send->gain_control()->Changed.connect (send_connections, MISSING_INVALIDATOR, std::bind (&OSCCueObserver::send_gain_message, this, i + 1, std::weak_ptr(send->gain_control()), false), OSC::instance()); send_gain_message (i + 1, send->gain_control(), true); @@ -246,10 +246,8 @@ OSCCueObserver::send_gain_message (uint32_t id, std::weak_ptr wea return; } if (id) { - _osc.text_message_with_id (X_("/cue/send/name"), id, string_compose ("%1%2%3", std::fixed, std::setprecision(2), accurate_coefficient_to_dB (controllable->get_value())), true, addr); _osc.float_message_with_id (X_("/cue/send/fader"), id, controllable->internal_to_interface (controllable->get_value()), true, addr); } else { - _osc.text_message (X_("/cue/name"), string_compose ("%1%2%3", std::fixed, std::setprecision(2), accurate_coefficient_to_dB (controllable->get_value())), addr); _osc.float_message (X_("/cue/fader"), controllable->internal_to_interface (controllable->get_value()), addr); } diff --git a/libs/surfaces/osc/osc_cue_observer.h b/libs/surfaces/osc/osc_cue_observer.h index b31bf56596..0243e76c3b 100644 --- a/libs/surfaces/osc/osc_cue_observer.h +++ b/libs/surfaces/osc/osc_cue_observer.h @@ -60,7 +60,7 @@ class OSCCueObserver ArdourSurface::OSC::OSCSurface* sur; float _last_meter; float _last_signal; - std::vector gain_timeout; + std::map gain_timeout; bool tick_enable; std::map _last_gain;