From 3f4d70c32a938b9faa3e71b9861431703c2f9798 Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Thu, 21 Sep 2023 22:48:11 +0200 Subject: [PATCH] Fix null pointer assertions in buffer management --- CHANGELOG.md | 7 +++++++ src/wrapper/util/buffer_management.rs | 8 ++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b389ee87..9224241c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,13 @@ Since there is no stable release yet, the changes are organized per day in reverse chronological order. The main purpose of this document in its current state is to list breaking changes. +## [2023-05-21] + +### Fixed + +- Fixed null pointers assertions in the low level buffer management code not + working correctly. + ## [2023-09-03] ### Added diff --git a/src/wrapper/util/buffer_management.rs b/src/wrapper/util/buffer_management.rs index 98777d7a..763982ca 100644 --- a/src/wrapper/util/buffer_management.rs +++ b/src/wrapper/util/buffer_management.rs @@ -191,9 +191,9 @@ impl BufferManager { .enumerate() .take(output_channel_pointers.num_channels) { + assert!(!output_channel_pointers.ptrs.as_ptr().is_null()); let output_channel_pointer = output_channel_pointers.ptrs.as_ptr().add(channel_idx); - assert!(!output_channel_pointer.is_null()); *output_slice = std::slice::from_raw_parts_mut( (*output_channel_pointer).add(sample_offset), @@ -229,9 +229,9 @@ impl BufferManager { .enumerate() .take(input_channel_pointers.num_channels) { + assert!(!input_channel_pointers.ptrs.as_ptr().is_null()); let input_channel_pointer = input_channel_pointers.ptrs.as_ptr().add(channel_idx); - assert!(!input_channel_pointer.is_null()); output_slice.copy_from_slice(std::slice::from_raw_parts_mut( (*input_channel_pointer).add(sample_offset), @@ -273,9 +273,9 @@ impl BufferManager { .enumerate() .take(input_channel_pointers.num_channels) { + assert!(!input_channel_pointers.ptrs.as_ptr().is_null()); let input_channel_pointer = input_channel_pointers.ptrs.as_ptr().add(channel_idx); - assert!(!input_channel_pointer.is_null()); nih_debug_assert!(num_samples <= channel.capacity()); channel.resize(num_samples, 0.0); @@ -334,9 +334,9 @@ impl BufferManager { .enumerate() .take(output_channel_pointers.num_channels) { + assert!(!output_channel_pointers.ptrs.as_ptr().is_null()); let output_channel_pointer = output_channel_pointers.ptrs.as_ptr().add(channel_idx); - assert!(!output_channel_pointer.is_null()); *output_slice = std::slice::from_raw_parts_mut( (*output_channel_pointer).add(sample_offset),