From 0e4000d41bff0a32c7f2261810ee87423dbd210e Mon Sep 17 00:00:00 2001
From: Zalewa <zalewapl@gmail.com>
Date: Sun, 19 Jan 2020 11:07:56 +0100
Subject: [PATCH 1/1] SRB2 server can have no WADs at all, anticipate that;
 should fix #3728

An assertion-caused crash would occur when trying to refresh SRB2 server
list and a one of those servers would not report any files loaded at all.

[linda@lindalap.fi: cherry-picked commit b623ab1 from the master branch]
Signed-off-by: Linda Lapinlampi <linda@lindalap.fi>
---
 CHANGELOG.md                    | 5 +++++
 src/plugins/srb2/CMakeLists.txt | 2 +-
 src/plugins/srb2/srb2server.cpp | 2 +-
 3 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 50731a3c..ced36eb7 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -8,6 +8,11 @@ This file follows the format of
 and this project does not adhere to
 [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
 
+## [Unreleased]
+### Fixed
+- SRB2: it's possible that a server will not report any files loaded.
+This possibility was not anticipated and if encountered, resulted in
+an assertion causing the whole program to close. (#3728)
 
 ## [1.3] - 2019-07-27
 ### Added
diff --git a/src/plugins/srb2/CMakeLists.txt b/src/plugins/srb2/CMakeLists.txt
index 07a2a4f9..213469ea 100644
--- a/src/plugins/srb2/CMakeLists.txt
+++ b/src/plugins/srb2/CMakeLists.txt
@@ -21,7 +21,7 @@
 cmake_minimum_required(VERSION 2.8.12)
 
 set(PLUGIN_NAME srb2)
-set(PLUGIN_VERSION 13)
+set(PLUGIN_VERSION 14)
 include(../PluginHeader.cmake)
 
 set(SRB2_FILES
diff --git a/src/plugins/srb2/srb2server.cpp b/src/plugins/srb2/srb2server.cpp
index 00067147..d5808495 100644
--- a/src/plugins/srb2/srb2server.cpp
+++ b/src/plugins/srb2/srb2server.cpp
@@ -394,7 +394,7 @@ Server::Response Srb2Server::processServerInfo(const ServerInfo &info)
 	setMap(info.mapName);
 	setGameMode(info.gameMode());
 
-	setIwad(info.files.first().name);
+	setIwad(!info.files.empty() ? info.files.first().name : "");
 	clearWads();
 	bool first = true;
 	for (const FileNeeded &file : info.files)
-- 
2.25.0

