Fix crash if tpt.installScriptManager fails

In which case the request completion handler code neglected to reset the unique_ptr holding the request.
This commit is contained in:
Tamás Bálint Misius 2024-02-29 19:02:45 +01:00
parent 79f45eb096
commit ef308c1e48
No known key found for this signature in database
GPG Key ID: 5B472A12F6ECA9F2

View File

@ -46,6 +46,7 @@ void LuaMisc::Tick(lua_State *L)
auto *lsi = GetLSI();
if (lsi->scriptManagerDownload && lsi->scriptManagerDownload->CheckDone())
{
auto scriptManagerDownload = std::move(lsi->scriptManagerDownload);
struct Status
{
struct Ok
@ -82,8 +83,8 @@ void LuaMisc::Tick(lua_State *L)
};
try
{
auto ret = lsi->scriptManagerDownload->StatusCode();
auto scriptData = lsi->scriptManagerDownload->Finish().second;
auto ret = scriptManagerDownload->StatusCode();
auto scriptData = scriptManagerDownload->Finish().second;
if (!scriptData.size())
{
complete({ Status::GetFailed{ "Server did not return data" } });
@ -111,7 +112,6 @@ void LuaMisc::Tick(lua_State *L)
{
complete({ Status::GetFailed{ ByteString(ex.what()).FromUtf8() } });
}
lsi->scriptManagerDownload.reset();
}
}