winmm_midi: Fix midi_write_long_event unable to send sysex correctly (#16804)

data size has to be DWORD aligned.

Fix https://github.com/libretro/RetroArch/issues/16790

review before merge for confirmation/corrections:
@LibretroAdmin @zoltanvb and others
This commit is contained in:
negativeExponent 2024-07-23 10:08:29 +08:00 committed by GitHub
parent 3ba8171ed8
commit 240e5eb9e5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -343,6 +343,9 @@ static bool winmm_midi_write_long_event(winmm_midi_buffer_t *buf,
{
DWORD i = buf->header.dwBytesRecorded / sizeof(DWORD);
/* data size has to be DWORD aligned */
data_size = (data_size + (sizeof(DWORD) - 1)) & ~(sizeof(DWORD) - 1);
if (buf->header.dwBytesRecorded + sizeof(DWORD) * 3 + data_size >
sizeof(DWORD) * WINMM_MIDI_BUF_LEN)
return false;