From f309f39982431163ed23f4cf7b3daaffcc96882e Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Tue, 28 Jun 2022 22:24:57 +0200 Subject: [PATCH] More defensively check for >0 inputs and outputs Noticed this through a bug in clapval. --- src/wrapper/clap/wrapper.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/wrapper/clap/wrapper.rs b/src/wrapper/clap/wrapper.rs index 2b512722..f5cf6a42 100644 --- a/src/wrapper/clap/wrapper.rs +++ b/src/wrapper/clap/wrapper.rs @@ -1639,7 +1639,7 @@ impl Wrapper

{ let current_bus_config = wrapper.current_bus_config.load(); let has_main_input = current_bus_config.num_input_channels > 0; let has_main_output = current_bus_config.num_output_channels > 0; - if !process.audio_outputs.is_null() { + if process.audio_outputs_count > 0 && !process.audio_outputs.is_null() { for output_idx in if has_main_output { 1 } else { 0 }..process.audio_outputs_count as isize { @@ -1724,7 +1724,8 @@ impl Wrapper

{ // Explicitly take plugins with no main output that does have auxiliary outputs // into account. Shouldn't happen, but if we just start copying audio here then // that would result in unsoundness. - if !process.audio_outputs.is_null() + if process.audio_outputs_count > 0 + && !process.audio_outputs.is_null() && !(*process.audio_outputs).data32.is_null() && !output_slices.is_empty() { @@ -1759,8 +1760,10 @@ impl Wrapper

{ // Some hosts process data in place, in which case we don't need to do any copying // ourselves. If the pointers do not alias, then we'll do the copy here and then the // plugin can just do normal in place processing. - if !process.audio_outputs.is_null() + if process.audio_outputs_count > 0 + && !process.audio_outputs.is_null() && !(*process.audio_outputs).data32.is_null() + && process.audio_inputs_count > 0 && !process.audio_inputs.is_null() && !(*process.audio_inputs).data32.is_null() {