From b9a7f2c8004073871a698385fcf364639df02919 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Tue, 15 Aug 2017 19:49:15 +0200 Subject: GRAPHICS: MACGUI: Fix crash in selection when there is no text found --- graphics/macgui/mactextwindow.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'graphics/macgui/mactextwindow.cpp') diff --git a/graphics/macgui/mactextwindow.cpp b/graphics/macgui/mactextwindow.cpp index a45d1d641b..9a1898b044 100644 --- a/graphics/macgui/mactextwindow.cpp +++ b/graphics/macgui/mactextwindow.cpp @@ -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()); -- cgit v1.2.3