summaryrefslogtreecommitdiff
path: root/ism/src/scim_helper.cpp
diff options
context:
space:
mode:
authorWonkeun Oh <wonkeun.oh@samsung.com>2016-05-19 19:19:01 +0900
committerWonkeun Oh <wonkeun.oh@samsung.com>2016-05-19 20:31:10 +0900
commitc193d01ad652b8da3bcd2b80e5ba271314228771 (patch)
treef6be877cfed86a35e1f9589b3aee7aa56e432713 /ism/src/scim_helper.cpp
parentde78f700d5be6b15157a6e6fa0ec8995834ae915 (diff)
downloadisf-c193d01ad652b8da3bcd2b80e5ba271314228771.tar.gz
isf-c193d01ad652b8da3bcd2b80e5ba271314228771.tar.bz2
isf-c193d01ad652b8da3bcd2b80e5ba271314228771.zip
Fixed the crash issue when the surrounding text is null
Change-Id: I8e2e0cbb7e68192eda28867c8c063854b79b578c
Diffstat (limited to 'ism/src/scim_helper.cpp')
-rw-r--r--ism/src/scim_helper.cpp17
1 files changed, 16 insertions, 1 deletions
diff --git a/ism/src/scim_helper.cpp b/ism/src/scim_helper.cpp
index 5a74a582..0b6a67f8 100644
--- a/ism/src/scim_helper.cpp
+++ b/ism/src/scim_helper.cpp
@@ -1954,6 +1954,12 @@ HelperAgent::get_surrounding_text (int maxlen_before, int maxlen_after, String &
{
LOGD ("");
+ if (!m_impl || !m_impl->surrounding_text) {
+ text = utf8_wcstombs (WideString ());
+ cursor = 0;
+ return;
+ }
+
WideString before = utf8_mbstowcs (String (m_impl->surrounding_text));
if (m_impl->cursor_pos > before.length ())
@@ -1983,7 +1989,16 @@ void
HelperAgent::delete_surrounding_text (int offset, int len) const
{
LOGD ("offset = %d, len = %d", offset, len);
- WideString ws = utf8_mbstowcs (m_impl->surrounding_text);
+
+ if (!m_impl)
+ return;
+
+ WideString ws;
+
+ if (!m_impl->surrounding_text)
+ ws = utf8_mbstowcs (String (""));
+ else
+ ws = utf8_mbstowcs (String (m_impl->surrounding_text));
int _offset = offset + m_impl->cursor_pos;