diff --git a/src/events.rs b/src/events.rs index 1dd3acd0..2dae7081 100644 --- a/src/events.rs +++ b/src/events.rs @@ -220,6 +220,10 @@ impl EventBuffer { ) }; + if current_packet_ptr.is_null() { + panic!("MIDIEventListAdd was unable to add the event") + } + self.current_packet_offset = unsafe { (current_packet_ptr as *const u8).offset_from(packet_list_ptr as *const u8) as usize }; diff --git a/src/packets.rs b/src/packets.rs index 2e1a50a1..a1c85ee4 100644 --- a/src/packets.rs +++ b/src/packets.rs @@ -205,6 +205,11 @@ impl PacketBuffer { data.as_ptr(), ) }; + + if current_packet_ptr.is_null() { + panic!("MIDIPacketListAdd was unable to add the packet") + } + let current_packet_offset = unsafe { (current_packet_ptr as *const u8).offset_from(packet_list_ptr as *const u8) as usize }; @@ -281,6 +286,10 @@ impl PacketBuffer { ) }; + if current_packet_ptr.is_null() { + panic!("MIDIPacketListAdd was unable to add the packet") + } + self.current_packet_offset = unsafe { (current_packet_ptr as *const u8).offset_from(packet_list_ptr as *const u8) as usize };