fixed bug with accessing string buffer that was already free()'ed
authorHolger Schemel <info@artsoft.org>
Thu, 30 Aug 2018 18:11:08 +0000 (20:11 +0200)
committerHolger Schemel <info@artsoft.org>
Thu, 30 Aug 2018 18:11:08 +0000 (20:11 +0200)
The function "getNetworkLevelDir()" returns a reference to a string
buffer that will be invalidated by each following invocation. As
"InitNetworkLevelDirectory()" also calls this function, it must be
called before "getNetworkLevelDir()".

src/network.c

index d780e0d548ecb0755171fd599fb670cd95652629..574809781e92dcbbb4cf5a75c78b34f65dc5f220 100644 (file)
@@ -824,6 +824,9 @@ static void Handle_OP_LEVEL_FILE()
   printf("OP_LEVEL_FILE: %d\n", player_nr);
 
   leveldir_identifier = getStringCopy(getNetworkBufferString(read_buffer));
+
+  InitNetworkLevelDirectory(leveldir_identifier);
+
   network_level_dir   = getNetworkLevelDir(leveldir_identifier);
 
   file_info->nr       = getNetworkBuffer16BitInteger(read_buffer);
@@ -832,8 +835,6 @@ static void Handle_OP_LEVEL_FILE()
   file_info->basename = getStringCopy(getNetworkBufferString(read_buffer));
   file_info->filename = getPath2(network_level_dir, file_info->basename);
 
-  InitNetworkLevelDirectory(leveldir_identifier);
-
   getNetworkBufferFile(read_buffer, file_info->filename);
 
   use_custom_template = getNetworkBuffer8BitInteger(read_buffer);