← Back to team overview

widelands-dev team mailing list archive

[Merge] lp:~widelands-dev/widelands/bug-1826669-mp-map-b20 into lp:widelands

 

GunChleoc has proposed merging lp:~widelands-dev/widelands/bug-1826669-mp-map-b20 into lp:widelands.

Commit message:
Fix crash in NetClient when host changes their mind about a custom map in mid-transfer.

Requested reviews:
  Widelands Developers (widelands-dev)
Related bugs:
  Bug #1826669 in widelands: "R20-rc1 HeapUseAfterFree when changig Map during Download"
  https://bugs.launchpad.net/widelands/+bug/1826669

For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/bug-1826669-mp-map-b20/+merge/366618
-- 
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/bug-1826669-mp-map-b20 into lp:widelands.
=== added file 'WL_RELEASE'
--- WL_RELEASE	1970-01-01 00:00:00 +0000
+++ WL_RELEASE	2019-04-28 14:26:47 +0000
@@ -0,0 +1,1 @@
+build-20-rc1

=== modified file 'appveyor.yml'
--- appveyor.yml	2019-04-25 15:49:31 +0000
+++ appveyor.yml	2019-04-28 14:26:47 +0000
@@ -38,16 +38,20 @@
   - cmd: cd %APPVEYOR_BUILD_FOLDER%
   - cmd: md build
   - cmd: cd build
+<<<<<<< TREE
   - cmd: echo %APPVEYOR_BUILD_VERSION%_%CONFIGURATION%_%PLATFORM% > %APPVEYOR_BUILD_FOLDER%\WL_RELEASE
   - cmd: "IF \"%PLATFORM%\" == \"x86\" (cmake -G \"Ninja\" -DBoost_NO_BOOST_CMAKE=ON -DCMAKE_BUILD_TYPE=%CONFIGURATION% -DOPTION_USE_GLBINDING=OFF -DOPTION_BUILD_WEBSITE_TOOLS=OFF -DOPTION_ASAN=OFF -DCMAKE_JOB_POOLS=\"linking=1\" -DCMAKE_JOB_POOL_LINK=linking %APPVEYOR_BUILD_FOLDER%) ELSE (cmake -G \"Ninja\" -DBoost_NO_BOOST_CMAKE=ON -DCMAKE_BUILD_TYPE=%CONFIGURATION% -DOPTION_USE_GLBINDING=ON -DOPTION_BUILD_WEBSITE_TOOLS=OFF -DOPTION_ASAN=OFF -DCMAKE_JOB_POOLS=\"linking=1\" -DCMAKE_JOB_POOL_LINK=linking %APPVEYOR_BUILD_FOLDER%)"
+=======
+  - cmd: "IF \"%PLATFORM%\" == \"x86\" (cmake -G \"Ninja\" -DCMAKE_BUILD_TYPE=%CONFIGURATION% -DOPTION_USE_GLBINDING=OFF -DOPTION_BUILD_WEBSITE_TOOLS=OFF -DOPTION_ASAN=OFF -DCMAKE_JOB_POOLS=\"linking=1\" -DCMAKE_JOB_POOL_LINK=linking %APPVEYOR_BUILD_FOLDER%) ELSE (cmake -G \"Ninja\" -DCMAKE_BUILD_TYPE=%CONFIGURATION% -DOPTION_USE_GLBINDING=ON -DOPTION_BUILD_WEBSITE_TOOLS=OFF -DOPTION_ASAN=OFF -DCMAKE_JOB_POOLS=\"linking=1\" -DCMAKE_JOB_POOL_LINK=linking %APPVEYOR_BUILD_FOLDER%)"
+>>>>>>> MERGE-SOURCE
   - cmd: "cmake --build ."
 on_success:
   - cmd: strip -sv %APPVEYOR_BUILD_FOLDER%\build\src\widelands.exe
-  - cmd: ISCC /q /o%APPVEYOR_BUILD_FOLDER% /fWidelands-%APPVEYOR_BUILD_VERSION%-%CONFIGURATION%-%PLATFORM% c:\projects\widelands\utils\win32\innosetup\Widelands.iss
-  - appveyor PushArtifact %APPVEYOR_BUILD_FOLDER%\Widelands-%APPVEYOR_BUILD_VERSION%-%CONFIGURATION%-%PLATFORM%.exe
+  - cmd: ISCC /q /o%APPVEYOR_BUILD_FOLDER% /fWidelands-build20-rc1-%PLATFORM% c:\projects\widelands\utils\win32\innosetup\Widelands.iss
+  - appveyor PushArtifact %APPVEYOR_BUILD_FOLDER%\Widelands-build20-rc1-%PLATFORM%.exe
 
 artifacts:
-  - path: Widelands-$(APPVEYOR_BUILD_VERSION)-$(CONFIGURATION)-$(PLATFORM).exe
+  - path: Widelands-build20-rc1-$(PLATFORM).exe
     name: Widelands Setup
 
 platform:

=== modified file 'src/network/gameclient.cc'
--- src/network/gameclient.cc	2019-04-27 11:21:21 +0000
+++ src/network/gameclient.cc	2019-04-28 14:26:47 +0000
@@ -594,8 +594,7 @@
 		    d->settings.mapfilename.c_str());
 
 		// New map was set, so we clean up the buffer of a previously requested file
-		if (file_)
-			delete file_;
+		file_.reset(nullptr);
 		break;
 	}
 
@@ -645,10 +644,7 @@
 		s.unsigned_8(NETCMD_NEW_FILE_AVAILABLE);
 		d->net->send(s);
 
-		if (file_)
-			delete file_;
-
-		file_ = new NetTransferFile();
+		file_.reset(new NetTransferFile());
 		file_->bytes = bytes;
 		file_->filename = path;
 		file_->md5sum = md5;

=== modified file 'src/network/gameclient.h'
--- src/network/gameclient.h	2019-03-15 15:11:57 +0000
+++ src/network/gameclient.h	2019-04-28 14:26:47 +0000
@@ -20,6 +20,8 @@
 #ifndef WL_NETWORK_GAMECLIENT_H
 #define WL_NETWORK_GAMECLIENT_H
 
+#include <memory>
+
 #include "chat/chat.h"
 #include "logic/game_controller.h"
 #include "logic/game_settings.h"
@@ -123,7 +125,7 @@
 	                bool sendreason = true,
 	                bool showmsg = true);
 
-	NetTransferFile* file_;
+	std::unique_ptr<NetTransferFile> file_;
 	GameClientImpl* d;
 	bool internet_;
 };

=== modified file 'src/network/gamehost.cc'
--- src/network/gamehost.cc	2019-03-15 15:11:57 +0000
+++ src/network/gamehost.cc	2019-04-28 14:26:47 +0000
@@ -531,7 +531,7 @@
 	hostuser.position = UserSettings::none();
 	hostuser.ready = true;
 	d->settings.users.push_back(hostuser);
-	file_ = nullptr;  //  Initialize as 0 pointer - unfortunately needed in struct.
+	file_.reset(nullptr);  //  Initialize as 0 pointer - unfortunately needed in struct.
 }
 
 GameHost::~GameHost() {
@@ -546,7 +546,6 @@
 	d->net.reset();
 	d->promoter.reset();
 	delete d;
-	delete file_;
 }
 
 const std::string& GameHost::get_local_playername() const {
@@ -1083,9 +1082,7 @@
 		// Read in the file
 		FileRead fr;
 		fr.open(*g_fs, mapfilename);
-		if (file_)
-			delete file_;
-		file_ = new NetTransferFile();
+		file_.reset(new NetTransferFile());
 		file_->filename = mapfilename;
 		uint32_t leftparts = file_->bytes = fr.get_size();
 		while (leftparts > 0) {
@@ -1104,10 +1101,7 @@
 		file_->md5sum = md5sum.get_checksum().str();
 	} else {
 		// reset previously offered map / saved game
-		if (file_) {
-			delete file_;
-			file_ = nullptr;
-		}
+		file_.reset(nullptr);
 	}
 
 	packet.reset();

=== modified file 'src/network/gamehost.h'
--- src/network/gamehost.h	2019-03-15 15:11:57 +0000
+++ src/network/gamehost.h	2019-04-28 14:26:47 +0000
@@ -20,6 +20,8 @@
 #ifndef WL_NETWORK_GAMEHOST_H
 #define WL_NETWORK_GAMEHOST_H
 
+#include <memory>
+
 #include "logic/game_controller.h"
 #include "logic/game_settings.h"
 #include "logic/player_end_result.h"
@@ -157,7 +159,7 @@
 	                       const std::string& arg = "");
 	void reaper();
 
-	NetTransferFile* file_;
+	std::unique_ptr<NetTransferFile> file_;
 	GameHostImpl* d;
 	bool internet_;
 	bool forced_pause_;

=== modified file 'src/network/network.h'
--- src/network/network.h	2019-02-23 11:00:49 +0000
+++ src/network/network.h	2019-04-28 14:26:47 +0000
@@ -181,6 +181,11 @@
 };
 
 struct NetTransferFile {
+	NetTransferFile() : bytes(0), filename(""), md5sum("") {
+	}
+	~NetTransferFile() {
+		parts.clear();
+	}
 	uint32_t bytes;
 	std::string filename;
 	std::string md5sum;

=== modified file 'utils/macos/fix_dependencies.py'
--- utils/macos/fix_dependencies.py	2019-04-24 07:07:59 +0000
+++ utils/macos/fix_dependencies.py	2019-04-28 14:26:47 +0000
@@ -12,12 +12,18 @@
 import os
 import shutil
 import subprocess
+<<<<<<< TREE
 import hashlib
 
 
 def hash_file(fn):
     return hashlib.sha1(open(fn, 'rb').read()).hexdigest()
+=======
+import hashlib
+>>>>>>> MERGE-SOURCE
 
+def hash_file(fn):
+    return hashlib.sha1(open(fn,'rb').read()).hexdigest()
 
 def get_dependencies(loading_binary):
     out = subprocess.check_output(['/usr/bin/otool', '-L', loading_binary])
@@ -90,8 +96,13 @@
 
     for binary in to_fix:
         print('Fixing binary: %s' % binary)
+<<<<<<< TREE
         if binary.endswith('.dylib'):
             change_id(binary)
+=======
+        if binary.endswith(".dylib"):
+            change_id(binary)
+>>>>>>> MERGE-SOURCE
         for (dep_name, dep_path) in all_dependencies.items():
             subprocess.check_call(['/usr/bin/install_name_tool', '-change',
                                    dep_name, '@executable_path/' + p.basename(dep_path), binary])

=== modified file 'utils/win32/innosetup/Widelands.iss'
--- utils/win32/innosetup/Widelands.iss	2019-04-23 07:47:25 +0000
+++ utils/win32/innosetup/Widelands.iss	2019-04-28 14:26:47 +0000
@@ -37,7 +37,7 @@
 ;Appveyor environment
 #define BuildFolder GetEnv("APPVEYOR_BUILD_FOLDER")
 #define DLLFolder GetEnv("MINGWPATH")
-#define Version GetEnv("APPVEYOR_BUILD_VERSION") + GetEnv("CONFIGURATION") + GetEnv("PLATFORM")
+#define Version "Build20-rc1-" + GetEnv("PLATFORM")
 
 [Setup]
 AppName={#Name}