Fix UB in modelasm chrinfo handler

This commit is contained in:
Ryan Dwyer 2023-08-19 19:14:10 +10:00
parent 032c5166f4
commit d7c94b4d04
3 changed files with 13 additions and 2 deletions

View File

@ -461,7 +461,9 @@ else ifeq ($(COMPILER), gcc)
$(C_O_FILES): OPT_LVL := $(GCC_OPT_LVL)
CFLAGS := $(C_DEFINES) -DAVOID_UB=1 $(INCLUDES) \
C_DEFINES += -DAVOID_UB
CFLAGS := $(C_DEFINES) $(INCLUDES) \
-EB \
-march=vr4300 \
-mabi=32 \

View File

@ -818,7 +818,11 @@ glabel modelasm00018680
beqz $a1, .L000194a0
lw $t0, 0x4($gp)
lhu $t2, 0x0($a2)
#ifdef AVOID_UB
beqz $t2, .L0001946c
#else
beqz $a2, .L0001946c
#endif
lhu $t1, 0x0($t0)
mtc1 $zero, $f29
lwc1 $f30, 0x7e0($sp)

View File

@ -453,7 +453,12 @@ bool modelasm00018680(struct modelrenderdata *renderdata, struct model *model)
if (model) {
t1 = node->rodata->chrinfo.animpart;
if (anim) {
#ifdef AVOID_UB
if (anim->animnum)
#else
if (anim)
#endif
{
if (f30 != 0.0f) {
if (anim->flip) {
t2ptr8 = skeleton->things[t1];