Skip to content

Commit

Permalink
Log #836 and crash on it explicitly
Browse files Browse the repository at this point in the history
  • Loading branch information
lhog committed Jun 4, 2023
1 parent 85a97dd commit fb68676
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion rts/System/LoadSave/DemoRecorder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,15 @@ void CDemoRecorder::WriteDemoFile()
void CDemoRecorder::WriteSetupText(const std::string& text)
{
int length = text.length();
while (text[length - 1] == '\0') {
while (length > 0 && text[length - 1] == '\0') {
--length;
}

if (length <= 0) {
LOG_L(L_ERROR, "[CDemoRecorder::%s] Invalid game setup text (len %d):\n%s", __func__, static_cast<int32_t>(text.length()), text.c_str());
throw std::runtime_error("Invalid game setup text");
}

fileHeader.scriptSize = length;
demoStreams[isServerDemo].append(text.c_str(), length);
}
Expand Down

0 comments on commit fb68676

Please sign in to comment.