From b0b69bd780e5a8ed2a2a4978aa8008a8af7a64e5 Mon Sep 17 00:00:00 2001 From: Alexander Batalov Date: Fri, 9 Dec 2022 00:52:03 +0300 Subject: [PATCH] Fix wmMapIdxToName --- src/map.cc | 2 +- src/worldmap.cc | 4 ++-- src/worldmap.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/map.cc b/src/map.cc index 7f565b7..90c2639 100644 --- a/src/map.cc +++ b/src/map.cc @@ -799,7 +799,7 @@ int mapLoadById(int map) scriptSetFixedParam(gMapSid, map); char name[16]; - if (wmMapIdxToName(map, name) == -1) { + if (wmMapIdxToName(map, name, sizeof(name)) == -1) { return -1; } diff --git a/src/worldmap.cc b/src/worldmap.cc index ed4be1b..c481510 100644 --- a/src/worldmap.cc +++ b/src/worldmap.cc @@ -2761,14 +2761,14 @@ int wmMapMaxCount() } // 0x4BF974 -int wmMapIdxToName(int mapIdx, char* dest) +int wmMapIdxToName(int mapIdx, char* dest, size_t size) { if (mapIdx == -1 || mapIdx > wmMaxMapNum) { dest[0] = '\0'; return -1; } - snprintf(dest, sizeof(dest), "%s.MAP", wmMapInfoList[mapIdx].mapFileName); + snprintf(dest, size, "%s.MAP", wmMapInfoList[mapIdx].mapFileName); return 0; } diff --git a/src/worldmap.h b/src/worldmap.h index b6c5fcd..1180d70 100644 --- a/src/worldmap.h +++ b/src/worldmap.h @@ -237,7 +237,7 @@ int wmWorldMap_reset(); int wmWorldMap_save(File* stream); int wmWorldMap_load(File* stream); int wmMapMaxCount(); -int wmMapIdxToName(int mapIdx, char* dest); +int wmMapIdxToName(int mapIdx, char* dest, size_t size); int wmMapMatchNameToIdx(char* name); bool wmMapIdxIsSaveable(int mapIdx); bool wmMapIsSaveable();