Skip to content

Commit

Permalink
Fix crash if tpt.installScriptManager fails
Browse files Browse the repository at this point in the history
In which case the request completion handler code neglected to reset the unique_ptr holding the request.
  • Loading branch information
LBPHacker committed Feb 29, 2024
1 parent 79f45eb commit ef308c1
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/lua/LuaMisc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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" } });
Expand Down Expand Up @@ -111,7 +112,6 @@ void LuaMisc::Tick(lua_State *L)
{
complete({ Status::GetFailed{ ByteString(ex.what()).FromUtf8() } });
}
lsi->scriptManagerDownload.reset();
}
}

Expand Down

0 comments on commit ef308c1

Please sign in to comment.