summaryrefslogtreecommitdiff
path: root/src/audio
diff options
context:
space:
mode:
authorAnghelo Carvajal <angheloalf95@gmail.com>2023-06-24 04:40:26 -0400
committerGitHub <noreply@github.com>2023-06-24 18:40:26 +1000
commit9b341a4d6a721b46baa81ee2f47815b6073f5096 (patch)
treee1c5794f5111d3db2d628b8590e1c5a1b4b34d12 /src/audio
parent19da43859e700a3f312133130e9d897b33e5f389 (diff)
A few UB fixes (#1272)
* Fix OoB in ObjDriftie * Fix OoB in EnHorseLinkChild * Fix negative shift in jpegdecode * more oob fixes * AVOID_UB * clean * huh? * change viint.h macros * objdriftice * ub labelling * review * review * fix z_parameter arrays * u32 cast * missing &
Diffstat (limited to 'src/audio')
-rw-r--r--src/audio/lib/heap.c4
-rw-r--r--src/audio/lib/load.c2
2 files changed, 5 insertions, 1 deletions
diff --git a/src/audio/lib/heap.c b/src/audio/lib/heap.c
index 7a7cd5807..5d8dfee89 100644
--- a/src/audio/lib/heap.c
+++ b/src/audio/lib/heap.c
@@ -1109,7 +1109,9 @@ void* AudioHeap_AllocPermanent(s32 tableType, s32 id, size_t size) {
gAudioCtx.permanentEntries[index].size = size;
//! @bug UB: missing return. "addr" is in v0 at this point, but doing an
// explicit return uses an additional register.
- // return addr;
+#ifdef AVOID_UB
+ return addr;
+#endif
}
void* AudioHeap_AllocSampleCache(size_t size, s32 sampleBankId, void* sampleAddr, s8 medium, s32 cache) {
diff --git a/src/audio/lib/load.c b/src/audio/lib/load.c
index af9de1cd1..34e8dec9c 100644
--- a/src/audio/lib/load.c
+++ b/src/audio/lib/load.c
@@ -738,6 +738,7 @@ void* AudioLoad_SyncLoad(s32 tableType, u32 id, s32* didAllocate) {
romAddr = table->entries[realId].romAddr;
switch (cachePolicy) {
case CACHE_LOAD_PERMANENT:
+ //! @bug UB: triggers an UB because this function is missing a return value.
ramAddr = AudioHeap_AllocPermanent(tableType, realId, size);
if (ramAddr == NULL) {
return ramAddr;
@@ -1108,6 +1109,7 @@ void* AudioLoad_AsyncLoadInner(s32 tableType, s32 id, s32 nChunks, s32 retData,
switch (cachePolicy) {
case CACHE_LOAD_PERMANENT:
+ //! @bug UB: triggers an UB because this function is missing a return value.
ramAddr = AudioHeap_AllocPermanent(tableType, realId, size);
if (ramAddr == NULL) {
return ramAddr;