From: Ji-hoon Lee Date: Mon, 27 Nov 2017 11:16:04 +0000 (+0900) Subject: Check pos variable before using substr() function X-Git-Tag: accepted/tizen/unified/20171205.155510~9 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=187e057eb6a3d48fc626a834e2933a99b9076992;p=platform%2Fcore%2Fuifw%2Fisf.git Check pos variable before using substr() function Change-Id: I8a5ebfb3fcbe5936e336da2751178f6cf03165b8 --- diff --git a/ism/src/scim_helper.cpp b/ism/src/scim_helper.cpp index 9c26674..2a79425 100644 --- a/ism/src/scim_helper.cpp +++ b/ism/src/scim_helper.cpp @@ -2057,9 +2057,12 @@ HelperAgent::get_surrounding_text (int maxlen_before, int maxlen_after, String & String buffer = m_impl->finalized_text; cursor = m_impl->finalized_cursor_pos; int pos = cursor - maxlen_before; + if (maxlen_before < 0) pos = 0; + if (pos > (int)buffer.length()) pos = (int)buffer.length(); if (pos < 0) pos = 0; int len = maxlen_after + (cursor - pos); - if (len < 0) len = INT_MAX; + if (len < 0) len = 0; + if (maxlen_after < 0 ) len = String::npos; text = buffer.substr (pos, len); } else { text.clear ();