1
0
Fork 0

Prevent incorrect pointer derefs in debug asserts

This commit is contained in:
Robbert van der Helm 2023-02-26 01:14:06 +01:00
parent 878d0e5330
commit 767cff6294
2 changed files with 24 additions and 6 deletions

View file

@ -2119,9 +2119,16 @@ impl<P: ClapPlugin> Wrapper<P> {
{ {
nih_debug_assert!(host_input_idx < process.audio_inputs_count as usize); nih_debug_assert!(host_input_idx < process.audio_inputs_count as usize);
nih_debug_assert!(!process.audio_inputs.is_null()); nih_debug_assert!(!process.audio_inputs.is_null());
nih_debug_assert!(!(*host_input).data32.is_null());
nih_debug_assert!(!storage.is_empty()); nih_debug_assert!(!storage.is_empty());
nih_debug_assert_eq!((*host_input).channel_count, buffer.channels() as u32); if !process.audio_inputs.is_null()
&& host_input_idx < process.audio_inputs_count as usize
{
nih_debug_assert!(!(*host_input).data32.is_null());
nih_debug_assert_eq!(
(*host_input).channel_count,
buffer.channels() as u32
);
}
// If the host passes weird data then we need to be very sure that there are // If the host passes weird data then we need to be very sure that there are
// no dangling references to previous data // no dangling references to previous data
@ -2169,7 +2176,11 @@ impl<P: ClapPlugin> Wrapper<P> {
{ {
nih_debug_assert!(host_output_idx < process.audio_outputs_count as usize); nih_debug_assert!(host_output_idx < process.audio_outputs_count as usize);
nih_debug_assert!(!process.audio_outputs.is_null()); nih_debug_assert!(!process.audio_outputs.is_null());
if !process.audio_outputs.is_null()
&& host_output_idx < process.audio_outputs_count as usize
{
nih_debug_assert!(!(*host_output).data32.is_null()); nih_debug_assert!(!(*host_output).data32.is_null());
}
// If the host passes weird data then we need to be very sure that there are // If the host passes weird data then we need to be very sure that there are
// no dangling references to previous data // no dangling references to previous data

View file

@ -1383,9 +1383,14 @@ impl<P: Vst3Plugin> IAudioProcessor for Wrapper<P> {
{ {
nih_debug_assert!(host_input_idx < data.num_inputs as usize); nih_debug_assert!(host_input_idx < data.num_inputs as usize);
nih_debug_assert!(!data.inputs.is_null()); nih_debug_assert!(!data.inputs.is_null());
nih_debug_assert!(!(*host_input).buffers.is_null());
nih_debug_assert!(!storage.is_empty()); nih_debug_assert!(!storage.is_empty());
nih_debug_assert_eq!((*host_input).num_channels, buffer.channels() as i32); if !data.inputs.is_null() && host_input_idx < data.num_inputs as usize {
nih_debug_assert!(!(*host_input).buffers.is_null());
nih_debug_assert_eq!(
(*host_input).num_channels,
buffer.channels() as i32
);
}
// If the host passes weird data then we need to be very sure that there are // If the host passes weird data then we need to be very sure that there are
// no dangling references to previous data // no dangling references to previous data
@ -1434,7 +1439,9 @@ impl<P: Vst3Plugin> IAudioProcessor for Wrapper<P> {
{ {
nih_debug_assert!(host_output_idx < data.num_outputs as usize); nih_debug_assert!(host_output_idx < data.num_outputs as usize);
nih_debug_assert!(!data.outputs.is_null()); nih_debug_assert!(!data.outputs.is_null());
if !data.outputs.is_null() && host_output_idx < data.num_outputs as usize {
nih_debug_assert!(!(*host_output).buffers.is_null()); nih_debug_assert!(!(*host_output).buffers.is_null());
}
// If the host passes weird data then we need to be very sure that there are // If the host passes weird data then we need to be very sure that there are
// no dangling references to previous data // no dangling references to previous data