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 &
This commit is contained in:
Anghelo Carvajal
2023-06-24 04:40:26 -04:00
committed by GitHub
parent 19da43859e
commit 9b341a4d6a
10 changed files with 86 additions and 59 deletions
+3 -1
View File
@@ -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) {
+2
View File
@@ -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;