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.
This commit is contained in:
Milenko committed 2026-10-08 08:31:13 -04:00
1 parent 73dc01d09a
commit 22bb651e68
1 file changed
+6 -1
+6 -1
View File
@@ -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");
}