Skip to content

Commit

Permalink
GRAPHICS: MACGUI: Fix crash in selection when there is no text found
Browse files Browse the repository at this point in the history
  • Loading branch information
sev- committed Aug 15, 2017
1 parent 0f0dd88 commit b9a7f2c
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion graphics/macgui/mactextwindow.cpp
Expand Up @@ -257,9 +257,12 @@ Common::String MacTextWindow::cutSelection() {

const char *selStart = strstr(_inputText.c_str(), selection.c_str());

if (!selStart)
if (!selStart) {
warning("Cannot find substring '%s' in '%s'", selection.c_str(), _inputText.c_str());

return Common::String("");
}

int selPos = selStart - _inputText.c_str();

_inputText = Common::String(_inputText.c_str(), selPos) + Common::String(_inputText.c_str() + selPos + selection.size());
Expand Down

0 comments on commit b9a7f2c

Please sign in to comment.