From 22bb651e68fd8f52cd6d46b520f0da0bde11792e Mon Sep 17 00:00:00 2001 From: Milenko <39630670+MrMilenko@users.noreply.github.com> Date: Thu, 8 Oct 2026 08:31:13 -0400 Subject: [PATCH] Write the last multiplayer map's name from a buffer of the size written saved_game_file_remember_last_used_multiplayer_map wrote 256 bytes from the caller's name, which the menus' map list keeps in 64, so whatever followed it in memory went into lastmpmp.txt. The name is now copied into a zeroed buffer of the written size first. --- source/saved games/saved_game_files.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/source/saved games/saved_game_files.c b/source/saved games/saved_game_files.c index c179191e..2650c85f 100644 --- a/source/saved games/saved_game_files.c +++ b/source/saved games/saved_game_files.c @@ -851,17 +851,22 @@ void saved_game_file_remember_last_used_multiplayer_map( char const *map_name) { struct file_reference file; + /* port: the name in a buffer of the size written (callers' may be + smaller: the menus' map list's are 64 bytes), the rest zeros */ + char name[MAXIMUM_FILENAME_LENGTH+1]; match_assert( "c:\\halo\\SOURCE\\saved games\\saved_game_files.c", 1207, map_name); + csmemset(name, 0, sizeof(name)); + csstrncpy(name, map_name, sizeof(name) - 1); if (file_reference_create_from_path(&file, "z:\\lastmpmp.txt", FALSE) && file_create(&file) && file_open(&file, FLAG(_permission_write_bit))) { - if (!file_write(&file, MAXIMUM_FILENAME_LENGTH+1, map_name)) + if (!file_write(&file, MAXIMUM_FILENAME_LENGTH+1, name)) { error(_error_silent, "failed to write to '%s'", "z:\\lastmpmp.txt"); }