diff --git a/src/peep/peep.c b/src/peep/peep.c index 04668288a0..51bfe6b04d 100644 --- a/src/peep/peep.c +++ b/src/peep/peep.c @@ -426,6 +426,9 @@ static uint8 peep_assess_surroundings(sint16 center_x, sint16 center_y, sint16 c break; scenery = get_footpath_item_entry(footpath_element_get_path_scenery_index(mapElement)); + if (scenery == NULL) { + return PEEP_THOUGHT_TYPE_NONE; + } if (footpath_element_path_scenery_is_ghost(mapElement)) break; @@ -10893,6 +10896,10 @@ money32 set_peep_name(int flags, int state, uint16 sprite_index, uint8* text_1, void game_command_set_guest_name(int *eax, int *ebx, int *ecx, int *edx, int *esi, int *edi, int *ebp) { uint16 sprite_index = *ecx & 0xFFFF; + if (sprite_index >= MAX_SPRITES) { + *ebx = MONEY32_UNDEFINED; + return; + } rct_peep *peep = GET_PEEP(sprite_index); if (peep->type != PEEP_TYPE_GUEST) { *ebx = MONEY32_UNDEFINED; diff --git a/src/peep/staff.c b/src/peep/staff.c index 4030f1ef90..64dc1ebb27 100644 --- a/src/peep/staff.c +++ b/src/peep/staff.c @@ -1236,6 +1236,10 @@ int staff_path_finding(rct_peep* peep) { void game_command_set_staff_name(int *eax, int *ebx, int *ecx, int *edx, int *esi, int *edi, int *ebp) { uint16 sprite_index = *ecx & 0xFFFF; + if (sprite_index >= MAX_SPRITES) { + *ebx = MONEY32_UNDEFINED; + return; + } rct_peep *peep = GET_PEEP(sprite_index); if (peep->type != PEEP_TYPE_STAFF) { *ebx = MONEY32_UNDEFINED; diff --git a/src/ride/track_design.c b/src/ride/track_design.c index 30434ecd79..2c134ceb14 100644 --- a/src/ride/track_design.c +++ b/src/ride/track_design.c @@ -1393,6 +1393,9 @@ static money32 place_track_design(sint16 x, sint16 y, sint16 z, uint8 flags, uin } rct_track_td6 *td6 = gActiveTrackDesign; + if (td6 == NULL) { + return MONEY32_UNDEFINED; + } rct_object_entry *rideEntryObject = &td6->vehicle_object; uint8 entryType, entryIndex; diff --git a/src/windows/save_prompt.c b/src/windows/save_prompt.c index ef88877004..60d0de0191 100644 --- a/src/windows/save_prompt.c +++ b/src/windows/save_prompt.c @@ -120,6 +120,10 @@ void window_save_prompt_open() rct_widget *widgets; uint64 enabled_widgets; + if (gSavePromptMode >= countof(window_save_prompt_labels)) { + log_warning("Invalid save prompt mode %u", gSavePromptMode); + return; + } prompt_mode = gSavePromptMode; if (prompt_mode == PM_QUIT) prompt_mode = PM_SAVE_BEFORE_QUIT;