From d3c593666f04da23580b45f25b2b844519622bd6 Mon Sep 17 00:00:00 2001 From: Stan Date: Sat, 6 Feb 2021 23:00:45 +0000 Subject: [PATCH] Only parse querystring in RL Interface if it exists. Patch by: @irishninja Differential Revision: https://code.wildfiregames.com/D3529 This was SVN commit r24844. --- source/rlinterface/RLInterface.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/source/rlinterface/RLInterface.cpp b/source/rlinterface/RLInterface.cpp index 97317367c7..9675614110 100644 --- a/source/rlinterface/RLInterface.cpp +++ b/source/rlinterface/RLInterface.cpp @@ -140,14 +140,18 @@ void* Interface::MgCallback(mg_event event, struct mg_connection *conn, const st return handled; } ScenarioConfig scenario; - const std::string qs(request_info->query_string); - scenario.saveReplay = qs.find("saveReplay") != std::string::npos; + const char *query_string = request_info->query_string; + if (query_string != nullptr) + { + const std::string qs(query_string); + scenario.saveReplay = qs.find("saveReplay") != std::string::npos; - scenario.playerID = 1; - char playerID[1]; - const int len = mg_get_var(request_info->query_string, qs.length(), "playerID", playerID, 1); - if (len != -1) - scenario.playerID = std::stoi(playerID); + scenario.playerID = 1; + char playerID[1]; + const int len = mg_get_var(query_string, qs.length(), "playerID", playerID, 1); + if (len != -1) + scenario.playerID = std::stoi(playerID); + } scenario.content = std::move(data);