From e9834110ec05fcd03c64517a000dcd9a129df3c1 Mon Sep 17 00:00:00 2001 From: vsariola <5684185+vsariola@users.noreply.github.com> Date: Sat, 8 May 2021 16:51:45 +0300 Subject: [PATCH] fix(bridge): respect the hard limit of 64 delay lines to avoid crashes. --- vm/compiler/bridge/bridge.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/vm/compiler/bridge/bridge.go b/vm/compiler/bridge/bridge.go index fb77d5e..6f28f0e 100644 --- a/vm/compiler/bridge/bridge.go +++ b/vm/compiler/bridge/bridge.go @@ -23,6 +23,9 @@ func (s BridgeService) Compile(patch sointu.Patch) (sointu.Synth, error) { func Synth(patch sointu.Patch) (*C.Synth, error) { s := new(C.Synth) + if n := patch.NumDelayLines(); n > 64 { + return nil, fmt.Errorf("native bridge has currently a hard limit of 64 delaylines; patch uses %v", n) + } comPatch, err := vm.Encode(patch, vm.AllFeatures{}) if err != nil { return nil, fmt.Errorf("error compiling patch: %v", err) @@ -103,6 +106,9 @@ func (s *C.Synth) Release(voice int) { // Update func (s *C.Synth) Update(patch sointu.Patch) error { + if n := patch.NumDelayLines(); n > 64 { + return fmt.Errorf("native bridge has currently a hard limit of 64 delaylines; patch uses %v", n) + } comPatch, err := vm.Encode(patch, vm.AllFeatures{}) if err != nil { return fmt.Errorf("error compiling patch: %v", err)