Skip to content

Commit

Permalink
Fix null pointer assertions in buffer management
Browse files Browse the repository at this point in the history
  • Loading branch information
robbert-vdh committed Sep 21, 2023
1 parent c0a7266 commit 3f4d70c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions src/wrapper/util/buffer_management.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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),
Expand Down

0 comments on commit 3f4d70c

Please sign in to comment.