From c524a62c4069e16e20b361845cb7351414118d15 Mon Sep 17 00:00:00 2001 From: OBattler Date: Wed, 8 Jan 2020 19:01:24 +0100 Subject: [PATCH 1/2] Fixed an intance of undefined behavior in sb_mpu401.c. --- src/sound/snd_mpu401.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/sound/snd_mpu401.c b/src/sound/snd_mpu401.c index 5b4d2635b..03916ae3e 100644 --- a/src/sound/snd_mpu401.c +++ b/src/sound/snd_mpu401.c @@ -1216,7 +1216,8 @@ MPU401_Event(void *priv) mpu->clock.cth_counter++; if (mpu->clock.cth_counter >= mpu->clock.cth_rate[mpu->clock.cth_mode]) { mpu->clock.cth_counter = 0; - mpu->clock.cth_mode= (++mpu->clock.cth_mode) % 4; + mpu->clock.cth_mode++; + mpu->clock.cth_mode %= 4; mpu->state.req_mask |= (1 << 13); } } From 04931767e78a42393b2ebcb6a7ebeffbf0d1bcec Mon Sep 17 00:00:00 2001 From: TC1995 Date: Wed, 8 Jan 2020 19:05:21 +0100 Subject: [PATCH 2/2] Fixed compile error. --- src/sound/snd_mpu401.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sound/snd_mpu401.c b/src/sound/snd_mpu401.c index 03916ae3e..1ffc067f1 100644 --- a/src/sound/snd_mpu401.c +++ b/src/sound/snd_mpu401.c @@ -1394,7 +1394,7 @@ MPU401_InputMsg(void *p, uint8_t *msg) if (msg[1] == 123) { /* All notes off. */ for (key = 0; key < 128; key++) { - if (!(mpu->chanref[chrefnum].on && (mpu->chanref[chrefnum].M_GETKEY))) + if (!(mpu->chanref[chrefnum].on && (mpu->chanref[chrefnum].M_GETKEY))) { if (mpu->inputref[chan].on && mpu->inputref[chan].M_GETKEY) { midi_raw_out_byte(0x80 | chan); midi_raw_out_byte(key);