diff options
| author | Léo Lam <leo@leolam.fr> | 2021-06-12 19:41:00 +0200 |
|---|---|---|
| committer | Léo Lam <leo@leolam.fr> | 2021-06-12 19:41:00 +0200 |
| commit | 61ce332003a8b3bae093aaf8a84249b2cca70040 (patch) | |
| tree | 5853aeef5245bdf1f35b55910c0f90cefa0fd761 /src/KingSystem/Resource | |
| parent | 5c70f39dcddbf298dba460b6eee55cb3455a7b8c (diff) | |
ksys/res: Add AVOID_UB ifdef for bad memset in AnimInfo::parse_
Diffstat (limited to 'src/KingSystem/Resource')
| -rw-r--r-- | src/KingSystem/Resource/resResourceAnimInfo.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/KingSystem/Resource/resResourceAnimInfo.cpp b/src/KingSystem/Resource/resResourceAnimInfo.cpp index edee3386..6e0672d8 100644 --- a/src/KingSystem/Resource/resResourceAnimInfo.cpp +++ b/src/KingSystem/Resource/resResourceAnimInfo.cpp @@ -101,9 +101,13 @@ bool AnimInfo::parse_(u8* data, size_t size, sead::Heap* heap) { /// The only reason using SwordBlur::name doesn't crash is that Clang and GHS /// are smart enough to devirtualize sead::SafeString virtual function calls, /// which removes the need to go through the vtable. +#ifdef AVOID_UB + info->entries = new (heap) SwordBlur[info->num_entries]; +#else info->entries = static_cast<SwordBlur*>( heap->tryAlloc(sizeof(SwordBlur) * info->num_entries, alignof(SwordBlur))); std::memset(info->entries, 0, sizeof(SwordBlur) * info->num_entries); +#endif } // TODO / FIXME: finish this |
