Fixed buffer index overrun in connect_and_run()
[ardour.git] / libs / ardour / ladspa_plugin.cc
index afd0db860841e9692c7c7d68eaba2ed7796e02b4..50757f9acd2e3c87561595cd388f7e037cc17cfe 100644 (file)
@@ -95,7 +95,7 @@ LadspaPlugin::init (void *mod, uint32_t index, jack_nframes_t rate)
        _index = index;
 
        if (LADSPA_IS_INPLACE_BROKEN(descriptor->Properties)) {
-               error << compose(_("LADSPA: \"%1\" cannot be used, since it cannot do inplace processing"), descriptor->Name) << endmsg;
+               error << string_compose(_("LADSPA: \"%1\" cannot be used, since it cannot do inplace processing"), descriptor->Name) << endmsg;
                throw failed_constructor();
        }
        
@@ -325,7 +325,7 @@ LadspaPlugin::set_parameter (uint32_t which, float val)
                }
 
        } else {
-               warning << compose (_("illegal parameter number used with plugin \"%1\". This may"
+               warning << string_compose (_("illegal parameter number used with plugin \"%1\". This may"
                                      "indicate a change in the plugin design, and presets may be"
                                      "invalid"), name())
                        << endmsg;
@@ -426,7 +426,7 @@ LadspaPlugin::set_state(const XMLNode& node)
        LocaleGuard lg (X_("POSIX"));
 
        if (node.name() != state_node_name()) {
-               error << _("Bad node send to LadspaPlugin::set_state") << endmsg;
+               error << _("Bad node sent to LadspaPlugin::set_state") << endmsg;
                return -1;
        }
 
@@ -494,7 +494,7 @@ LadspaPlugin::set_state(const XMLNode& node)
                                }
 
                        } else {
-                               error << compose(_("LADSPA LadspaPlugin MIDI control specification for port %1 is incomplete, so it has been ignored"), port) << endl;
+                               error << string_compose(_("LADSPA LadspaPlugin MIDI control specification for port %1 is incomplete, so it has been ignored"), port) << endl;
                        }
                }
        }
@@ -609,16 +609,16 @@ LadspaPlugin::connect_and_run (vector<Sample*>& bufs, uint32_t nbufs, int32_t& i
        while (port_index < parameter_count()) {
                if (LADSPA_IS_PORT_AUDIO (port_descriptor(port_index))) {
                        if (LADSPA_IS_PORT_INPUT (port_descriptor(port_index))) {
-                               connect_port (port_index, bufs[min((uint32_t) in_index,nbufs)]);
+                               connect_port (port_index, bufs[min((uint32_t) in_index,nbufs - 1)] + offset);
                                //cerr << this << ' ' << name() << " @ " << offset << " inport " << in_index << " = buf " 
-                               //<< min((uint32_t)in_index,nbufs) << " = " << &bufs[min((uint32_t)in_index,nbufs)][offset] << endl;
+                               //     << min((uint32_t)in_index,nbufs) << " = " << &bufs[min((uint32_t)in_index,nbufs)][offset] << endl;
                                in_index++;
 
 
                        } else if (LADSPA_IS_PORT_OUTPUT (port_descriptor (port_index))) {
-                               connect_port (port_index, bufs[min((uint32_t) out_index,nbufs)]);
-                               //cerr << this << ' ' << name() << " @ " << offset << " outport " << out_index << " = buf " 
-                               //<< min((uint32_t)out_index,nbufs) << " = " << &bufs[min((uint32_t)out_index,nbufs)][offset] << endl;
+                               connect_port (port_index, bufs[min((uint32_t) out_index,nbufs - 1)] + offset);
+                               // cerr << this << ' ' << name() << " @ " << offset << " outport " << out_index << " = buf " 
+                               //     << min((uint32_t)out_index,nbufs) << " = " << &bufs[min((uint32_t)out_index,nbufs)][offset] << endl;
                                out_index++;
                        }
                }