GRAPHICS: MACGUI: Fix crash in selection when there is no text found

This commit is contained in:
Eugene Sandulenko 2017-08-15 19:49:15 +02:00
parent 0f0dd88b61
commit b9a7f2c800

View File

@ -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());