From d61220569d5e27c48c32b66bdc03ea431f22f243 Mon Sep 17 00:00:00 2001 From: cawtds <38510667+cawtds@users.noreply.github.com> Date: Thu, 27 Jun 2024 16:13:17 +0200 Subject: [PATCH 1/2] fix for potential UB in CameraObjectReset2 --- src/event_object_movement.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/event_object_movement.c b/src/event_object_movement.c index 43a5d86fe7..184081294b 100644 --- a/src/event_object_movement.c +++ b/src/event_object_movement.c @@ -2453,7 +2453,15 @@ u8 CameraObjectGetFollowedObjectId(void) void CameraObjectReset2(void) { +#ifdef UBFIX + struct Sprite* cameraObject = FindCameraObject(); + + if (cameraObject == NULL) + return; + cameraObject->data[1] = 2; +#else FindCameraObject()->data[1] = 2; +#endif } u8 CopySprite(struct Sprite *sprite, s16 x, s16 y, u8 subpriority) From 466a69a6e034c9726811bc2ad810cff66d2947f5 Mon Sep 17 00:00:00 2001 From: cawtds <38510667+cawtds@users.noreply.github.com> Date: Sat, 10 Aug 2024 20:41:21 +0200 Subject: [PATCH 2/2] Update src/event_object_movement.c Co-authored-by: GriffinR --- src/event_object_movement.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/event_object_movement.c b/src/event_object_movement.c index 184081294b..b55faee3f6 100644 --- a/src/event_object_movement.c +++ b/src/event_object_movement.c @@ -2453,15 +2453,12 @@ u8 CameraObjectGetFollowedObjectId(void) void CameraObjectReset2(void) { + struct Sprite *cameraObject = FindCameraObject(); #ifdef UBFIX - struct Sprite* cameraObject = FindCameraObject(); - if (cameraObject == NULL) return; - cameraObject->data[1] = 2; -#else - FindCameraObject()->data[1] = 2; #endif + cameraObject->data[1] = 2; } u8 CopySprite(struct Sprite *sprite, s16 x, s16 y, u8 subpriority)