Browse Source

Fixed memory corruption

git-svn-id: https://svn.code.sf.net/p/rathena/svn/branches/stable@1241 54d463be-8e91-2dee-dedb-b68131a5f0ec
amber 20 years ago
parent
commit
4a60e4af47
3 changed files with 12 additions and 9 deletions
  1. 2 0
      Changelog-SVN.txt
  2. 2 0
      src/common/core.c
  3. 8 9
      src/map/map.c

+ 2 - 0
Changelog-SVN.txt

@@ -1,6 +1,8 @@
 Date	Added
 
 03/17
+	* Fixed heap corrupion in map.c caused while loading maps 
+	  [SVN 1241: MouseJstr]
         * Re-fixed compile error in map.c -- sorry ^^; [celest]
         * trade.c fixed possibility of STORAGE+TRADE spooffing dupe [Lupus]
 	  Now, on accepting trade your active Storage window closes. (Either Common or Guils Storage)

+ 2 - 0
src/common/core.c

@@ -289,7 +289,9 @@ int main(int argc,char **argv)
 
 	display_title();
 
+#ifndef BCHECK
 	do_init_memmgr(argv[0]); // 一番最初に実行する必要がある
+#endif
 
 	tick_ = time(0);
 	ticks = gettick();

+ 8 - 9
src/map/map.c

@@ -1729,15 +1729,14 @@ int map_mapname2mapid(char *name) {
 
 	md = (struct map_data*)strdb_search(map_db,name);
 
-	#ifdef USE_AFM
-		// If we can't find the .gat map try .afm instead [celest]
-		if(md==NULL && strstr(name,".gat")) {
-			char afm_name[16] = "";
-			strncpy(afm_name, name, strlen(name) - 4);
-			strcat(afm_name, ".afm");
-			md = (struct map_data*)strdb_search(map_db,afm_name);
-		}
-	#endif
+#ifdef USE_AFM
+	// If we can't find the .gat map try .afm instead [celest]
+	if(md==NULL && strstr(name,".gat")) {
+	  char *afm_name = strdup(name);
+	  strcpy(&afm_name[strlen(name) - 3], "afm");
+	  md = (struct map_data*)strdb_search(map_db,afm_name);
+	}
+#endif
 
 	if(md==NULL || md->gat==NULL)
 		return -1;