From cd0bfa5d0c91944c015fae51e400c17b0b6f2113 Mon Sep 17 00:00:00 2001 From: "Carsten Haitzler (Rasterman)" Date: Fri, 15 Aug 2014 20:00:24 +0900 Subject: [PATCH] fix segv on word set search --- src/bin/termio.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/bin/termio.c b/src/bin/termio.c index 74acb681..2974b479 100644 --- a/src/bin/termio.c +++ b/src/bin/termio.c @@ -2597,19 +2597,18 @@ _codepoint_is_wordsep(const Eina_Unicode g) 0xff65, 0xe002a }; - size_t imax = sizeof(wordsep)/sizeof(wordsep[0]) - 1, + size_t imax = (sizeof(wordsep) / sizeof(wordsep[0])) - 1, imin = 0; - while (imax >= imin) - { - size_t imid = (imin + imax) / 2; - if (wordsep[imid] == g) - return EINA_TRUE; - else if (wordsep[imid] < g) - imin = imid + 1; - else - imax = imid - 1; - } + while (imax >= imin) + { + size_t imid = (imin + imax) / 2; + + if (wordsep[imid] == g) return EINA_TRUE; + else if (wordsep[imid] < g) imin = imid + 1; + else imax = imid - 1; + if ((imax == imin) || (imid == 0)) break; + } return EINA_FALSE; }