Repository navigation
midi_stream_decoder: copy an unterminated SysEx from its own F0; ignore empty buffers - #270
Open
nmplcpimenta wants to merge 1 commit into
Open
nmplcpimenta wants to merge 1 commit into
nmplcpimenta wants to merge 1 commit into
Conversation
…re empty buffers Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Member
|
heya! thanks, can you rebase on new master? I merged your other patch + some additional sysex fixes found during review |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
There are two bugs in
midi1::input_state_machine::on_bytes_multi_segmented(include/libremidi/detail/midi_stream_decoder.hpp):message.assign(bytes.begin(), bytes.begin() + size), which starts at the beginning of the buffer instead of at the F0. For example,90 3C 7F F0 7E 01followed by09 01 F7gives a note on and then the "SysEx"90 3C 7F 09 01 F7.has_finished_sysex, which callsfront()andback()on an empty span. This is undefined behaviour, and it trips the libc++ hardening assertionspan<T>::front() on empty span.on_bytes_segmentedalready returns early on an empty buffer.Change
bytes.begin() + i_byte.on_bytes_multi_segmentednow returns early on an empty buffer, ason_bytes_segmentedalready does.Tests
There is a new case in
tests/unit/midi_stream_decoder.cpp, "midi1: SysEx after other messages in one buffer":F0 7E 01 09 01 F7;on_bytes_multiandon_bytesproduce no messages.On the current master, the first check fails and the second aborts under libc++ hardening.
Relation to the SysEx PR
Related to #271, which rewrites this F0 branch and also never calls
front()on an empty span, so it fixes both bugs on its own. The two touch the same lines; whichever lands second, I'll rebase it. If #271 lands first, this PR shrinks to its test, which passes there as is.🤖 Generated with Claude Code