You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@impala.apache.org by wz...@apache.org on 2021/07/23 18:35:20 UTC
[impala] branch master updated: IMPALA-10819: Fix index overflow in
FindUtf8PosBackward
This is an automated email from the ASF dual-hosted git repository.
wzhou pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/impala.git
The following commit(s) were added to refs/heads/master by this push:
new 80b1cd9 IMPALA-10819: Fix index overflow in FindUtf8PosBackward
80b1cd9 is described below
commit 80b1cd9e226242926553e0242858512dceff497a
Author: stiga-huang <hu...@gmail.com>
AuthorDate: Fri Jul 23 10:09:41 2021 +0800
IMPALA-10819: Fix index overflow in FindUtf8PosBackward
In FindUtf8PosBackward, the first part of the while-loop is finding the
start byte of an UTF-8 character. We should check pos before using it.
Tests
- Manually ran string-util-test in ASAN build.
Change-Id: I9fab6a0b1a8e3a6fbe55fb45b04e86e9034f3ba7
Reviewed-on: http://gerrit.cloudera.org:8080/17717
Reviewed-by: Wenzhe Zhou <wz...@cloudera.com>
Tested-by: Impala Public Jenkins <im...@cloudera.com>
---
be/src/util/string-util.cc | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/be/src/util/string-util.cc b/be/src/util/string-util.cc
index b066052..1c11acd 100644
--- a/be/src/util/string-util.cc
+++ b/be/src/util/string-util.cc
@@ -115,7 +115,7 @@ int FindUtf8PosBackward(const uint8_t* ptr, const int len, int index) {
int last_pos = len;
while (pos >= 0) {
// Point to the start byte of the last character.
- while (!BitUtil::IsUtf8StartByte(ptr[pos]) && pos >= 0) --pos;
+ while (pos >= 0 && !BitUtil::IsUtf8StartByte(ptr[pos])) --pos;
if (pos < 0) {
// Can't find any legal characters. Count each byte from last_pos as one character.
// Note that index is 0-based.