Fixed the crash issue when the surrounding text is null 47/70547/3
authorWonkeun Oh <wonkeun.oh@samsung.com>
Thu, 19 May 2016 10:19:01 +0000 (19:19 +0900)
committerWonkeun Oh <wonkeun.oh@samsung.com>
Thu, 19 May 2016 11:31:10 +0000 (20:31 +0900)
Change-Id: I8e2e0cbb7e68192eda28867c8c063854b79b578c

ism/src/scim_helper.cpp

index 5a74a58..0b6a67f 100644 (file)
@@ -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;