diff options
| author | Tharo <17233964+Thar0@users.noreply.github.com> | 2024-02-28 14:06:03 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-02-28 09:06:03 -0500 |
| commit | 7a2c46d4eb4f3f0d12cae4f41df0e55342a42fd3 (patch) | |
| tree | 8a75bc50903f6c16c3d77a41193822f149780fa9 /src | |
| parent | c521f1f8ae6d1cb1f4210a8182519ade09b7f976 (diff) | |
AVOID_UB for out-of-bounds access in AudioLoad_Init (#1902)
Diffstat (limited to 'src')
| -rw-r--r-- | src/audio/lib/load.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/audio/lib/load.c b/src/audio/lib/load.c index c542c8062..0d2fe051d 100644 --- a/src/audio/lib/load.c +++ b/src/audio/lib/load.c @@ -1133,9 +1133,19 @@ void AudioLoad_Init(void* heap, u32 heapSize) { s32 i; u8* audioContextPtr = (u8*)&gAudioCtx; +#ifndef AVOID_UB + //! @bug This clearing loop sets one extra byte to 0 following gAudioCtx. + //! In practice this is harmless as it would set the most significant byte in gAudioCustomUpdateFunction to 0, + //! which was just reset to NULL above. for (i = sizeof(gAudioCtx); i >= 0; i--) { *audioContextPtr++ = 0; } +#else + // Avoid out-of-bounds variable access + for (i = sizeof(gAudioCtx); i > 0; i--) { + *audioContextPtr++ = 0; + } +#endif } // 1000 is a conversion from seconds to milliseconds |
