diff --git a/src/title.c b/src/title.c index ac5ac2040d..a7e947e94e 100644 --- a/src/title.c +++ b/src/title.c @@ -171,7 +171,7 @@ static void title_init_showcase() static int title_load_park(const char *path) { rct_window* w; - int successfulLoad; + int successfulLoad = 0; if (_strcmpi(path_get_extension(path), ".sv6") == 0) { SDL_RWops* rw = SDL_RWFromFile(path, "rb"); diff --git a/src/windows/editor_object_selection.c b/src/windows/editor_object_selection.c index 39efc7e727..034afb51f6 100644 --- a/src/windows/editor_object_selection.c +++ b/src/windows/editor_object_selection.c @@ -354,6 +354,10 @@ static void visible_list_refresh(rct_window *w) case RIDE_SORT_RIDE: sortFunc = visible_list_sort_ride_name; break; + default: + log_warning("Wrong sort type %d, leaving list as-is.", _listSortType); + window_invalidate(w); + return; } qsort(_listItems, _numListItems, sizeof(list_item), sortFunc); diff --git a/src/windows/editor_objective_options.c b/src/windows/editor_objective_options.c index 0a4909d758..2ffbd5af0f 100644 --- a/src/windows/editor_objective_options.c +++ b/src/windows/editor_objective_options.c @@ -785,10 +785,20 @@ static void window_editor_objective_options_main_textinput(rct_window *w, int wi break; case WIDX_SCENARIO_NAME: strncpy(s6Info->name, text, 64); + if (strnlen(s6Info->name, 64) == 64) + { + s6Info->name[64 - 1] = '\0'; + log_warning("Truncated S6 name: %s", s6Info->name); + } window_invalidate(w); break; case WIDX_DETAILS: strncpy(s6Info->details, text, 256); + if (strnlen(s6Info->details, 256) == 256) + { + s6Info->details[256 - 1] = '\0'; + log_warning("Truncated S6 name: %s", s6Info->details); + } window_invalidate(w); break; } diff --git a/src/windows/editor_scenario_options.c b/src/windows/editor_scenario_options.c index f1bb0880fb..4073444ec4 100644 --- a/src/windows/editor_scenario_options.c +++ b/src/windows/editor_scenario_options.c @@ -559,7 +559,7 @@ static void window_editor_scenario_options_financial_mousedown(int widgetIndex, break; } - if(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_PLAYING) { + if(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) == SCREEN_FLAGS_PLAYING) { window_invalidate_by_class(WC_FINANCES); window_invalidate_by_class(WC_BOTTOM_TOOLBAR); } diff --git a/src/windows/guest_list.c b/src/windows/guest_list.c index 517569c438..67d30bbddb 100644 --- a/src/windows/guest_list.c +++ b/src/windows/guest_list.c @@ -447,6 +447,9 @@ static void window_guest_list_scrollgetsize(rct_window *w, int scrollIndex, int w->var_492 = _window_guest_list_num_groups; y = _window_guest_list_num_groups * 21; break; + default: + log_error("Improper tab selected: %d, bailing out.", _window_guest_list_selected_tab); + return; } i = _window_guest_list_selected_page; diff --git a/src/windows/install_track.c b/src/windows/install_track.c index b0591080b7..08130e8f00 100644 --- a/src/windows/install_track.c +++ b/src/windows/install_track.c @@ -134,15 +134,16 @@ void window_install_track_open(const char* path) w->track_list.var_484 = 0; window_push_others_right(w); - memset(track_path, 0, MAX_PATH - 1); - strcpy(track_path, path); + strncpy(track_path, path, MAX_PATH); + track_path[MAX_PATH - 1] = '\0'; char* track_name_pointer = track_path; while (*track_name_pointer++ != '\0'); while (*--track_name_pointer != '\\'); track_name_pointer++; - strcpy(track_dest_name, track_name_pointer); + strncpy(track_dest_name, track_name_pointer, MAX_PATH); + track_dest_name[MAX_PATH - 1] = '\0'; window_invalidate(w); } @@ -153,7 +154,7 @@ void window_install_track_open(const char* path) */ static void window_install_track_select(rct_window *w, int index) { - uint8 *trackDesignItem, *trackDesignList = RCT2_ADDRESS(RCT2_ADDRESS_TRACK_LIST, uint8); + utf8 *trackDesignItem, *trackDesignList = RCT2_ADDRESS(RCT2_ADDRESS_TRACK_LIST, utf8); rct_track_design *trackDesign; w->track_list.var_480 = index; @@ -172,7 +173,7 @@ static void window_install_track_select(rct_window *w, int index) index--; trackDesignItem = trackDesignList + (index * 128); - RCT2_GLOBAL(0x00F4403C, uint8*) = trackDesignItem; + RCT2_GLOBAL(0x00F4403C, utf8*) = trackDesignItem; window_track_list_format_name( (char*)0x009BC313, diff --git a/src/windows/loadsave.c b/src/windows/loadsave.c index f5ebc59814..e4e2bdf200 100644 --- a/src/windows/loadsave.c +++ b/src/windows/loadsave.c @@ -602,6 +602,7 @@ static void window_loadsave_populate_list(int includeNewItem, bool browsable, co strncpy(_directory, directory, sizeof(_directory)); if (_extension != extension) { strncpy(_extension, extension, sizeof(_extension)); + _extension[sizeof(_extension) - 1] = '\0'; } _shortenedDirectory[0] = '\0'; @@ -921,7 +922,9 @@ static rct_window *window_overwrite_prompt_open(const char *name, const char *pa w->colours[0] = 154; strncpy(_window_overwrite_prompt_name, name, sizeof(_window_overwrite_prompt_name)); + _window_overwrite_prompt_name[sizeof(_window_overwrite_prompt_name) - 1] = '\0'; strncpy(_window_overwrite_prompt_path, path, sizeof(_window_overwrite_prompt_path)); + _window_overwrite_prompt_path[sizeof(_window_overwrite_prompt_path) - 1] = '\0'; return w; }