xbmc/xbmc — pull request #1848 by axmhari (2012-11-25 22:37:34+00:00)
Title: Fix possible crash in text editor dialog

When the text dialog is displayed more than once, it remembers the cursor position. As CGUIDialogKeyboardGeneric::SetText only moves the cursor by the string length, it will end up behind the end of the string. CGUILabelControl::SetCursorPos will correct the position, but for umlauts (ä, ö, ü, etc.) and similar characters CStdString gives the wrong string length. Pressing backspace then will lead to an exception, which is caught in the main loop. After the catch some portions of the application are deleted too early, so it will end up in an segmentation fault.

Therefore I applied the following fixes:
1. Convert the string to wide string in CGUILabelControl::SetCursorPos, to get proper length.
2. Set the cursor position directly for absolute positions, so that the position set in CGUIDialogKeyboardGeneric::SetText is already correct.

I also fixed the segmentation fault issue. Calling CApplication::Stop() in the catch(...) seemed safe to me, but I did not have a deeper look yet.