mirror of
https://github.com/zeldaret/oot.git
synced 2024-09-21 04:24:43 +00:00
AVOID_UB for out-of-bounds access in AudioLoad_Init (#1902)
This commit is contained in:
parent
c521f1f8ae
commit
7a2c46d4eb
@ -1133,9 +1133,19 @@ void AudioLoad_Init(void* heap, u32 heapSize) {
|
|||||||
s32 i;
|
s32 i;
|
||||||
u8* audioContextPtr = (u8*)&gAudioCtx;
|
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--) {
|
for (i = sizeof(gAudioCtx); i >= 0; i--) {
|
||||||
*audioContextPtr++ = 0;
|
*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
|
// 1000 is a conversion from seconds to milliseconds
|
||||||
|
Loading…
Reference in New Issue
Block a user