From 134aba4aa0e0617a2082cb86db7e1a7eb116c8e0 Mon Sep 17 00:00:00 2001 From: Kenix3 Date: Wed, 17 Jul 2024 14:35:13 -0400 Subject: [PATCH] Fixes crashes on asan related to audio. (#4049) Found in MM --- soh/soh/mixer.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/soh/soh/mixer.c b/soh/soh/mixer.c index 2e80ffb16..ba6a01bc1 100644 --- a/soh/soh/mixer.c +++ b/soh/soh/mixer.c @@ -99,8 +99,14 @@ void aClearBufferImpl(uint16_t addr, int nbytes) { memset(BUF_U8(addr), 0, nbytes); } -void aLoadBufferImpl(const void *source_addr, uint16_t dest_addr, uint16_t nbytes) { +void aLoadBufferImpl(const void* source_addr, uint16_t dest_addr, uint16_t nbytes) { +#if __SANITIZE_ADDRESS__ + for (size_t i = 0; i < ROUND_DOWN_16(nbytes); i++) { + BUF_U8(dest_addr)[i] = ((const unsigned char*)source_addr)[i]; + } +#else memcpy(BUF_U8(dest_addr), source_addr, ROUND_DOWN_16(nbytes)); +#endif } void aSaveBufferImpl(uint16_t source_addr, int16_t *dest_addr, uint16_t nbytes) {