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