From: Holger Schemel Date: Thu, 30 Aug 2018 18:11:08 +0000 (+0200) Subject: fixed bug with accessing string buffer that was already free()'ed X-Git-Tag: 4.1.1.0~49 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=c8058770312fb6ec95cd6a57164669031bfaf2bf;p=rocksndiamonds.git fixed bug with accessing string buffer that was already free()'ed 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()". --- diff --git a/src/network.c b/src/network.c index d780e0d5..57480978 100644 --- a/src/network.c +++ b/src/network.c @@ -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);