Skip to content

Commit

Permalink
Defensive coding practices sponsored by MtnDustin
Browse files Browse the repository at this point in the history
  • Loading branch information
lhecker committed Mar 14, 2023
1 parent 470b02c commit bfb11cd
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/host/readDataCooked.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1050,7 +1050,7 @@ void COOKED_READ_DATA::SavePendingInput(const size_t index, const bool multiline
const auto inputSizeAfter = input.size();
const auto amountConsumed = inputSizeBefore - inputSizeAfter;
input = { _backupLimit, _bytesRead / sizeof(wchar_t) };
input = input.substr(amountConsumed);
input = input.substr(std::min(input.size(), amountConsumed));
GetInputReadHandleData()->SaveMultilinePendingInput(input);
}
else if (!input.empty())
Expand Down
2 changes: 1 addition & 1 deletion src/host/stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ try
{
const auto inputSizeAfter = input.size();
const auto amountConsumed = inputSizeBefore - inputSizeAfter;
input = pending.substr(amountConsumed);
input = pending.substr(std::min(pending.size(), amountConsumed));
}

if (input.empty())
Expand Down

0 comments on commit bfb11cd

Please sign in to comment.