ksys/res: Add AVOID_UB ifdef for bad memset in AnimInfo::parse_

This commit is contained in:
Léo Lam 2021-06-12 19:41:00 +02:00
parent 5c70f39dcd
commit 61ce332003
No known key found for this signature in database
GPG Key ID: 0DF30F9081000741
1 changed files with 4 additions and 0 deletions

View File

@ -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