diff --git a/static_core/plugins/ets/sdk/native/api/ani_textencoder_helper.cpp b/static_core/plugins/ets/sdk/native/api/ani_textencoder_helper.cpp index 6b79928bc5c4b86900131b66f9f74755486723eb..87cd5a6f8959477e0f226abed1785d9aa4e31b62 100644 --- a/static_core/plugins/ets/sdk/native/api/ani_textencoder_helper.cpp +++ b/static_core/plugins/ets/sdk/native/api/ani_textencoder_helper.cpp @@ -96,11 +96,13 @@ bool Utf8ToUtf16LEByteCheck(const unsigned char *data, std::u16string &u16Str, s break; } case THREE_BYTES_STYLE: { - uint8_t c2 = data[i + 1]; - uint8_t c3 = data[i + 2]; if (i + TWO_MORE_BYTES_TO_CONSUME >= inputSizeBytes) { return false; } + // NOLINTBEGIN(cppcoreguidelines-pro-bounds-pointer-arithmetic) + uint8_t c2 = data[i + 1]; + uint8_t c3 = data[i + 2]; + // NOLINTEND(cppcoreguidelines-pro-bounds-pointer-arithmetic) i += TWO_MORE_BYTES_TO_CONSUME + 1; // CC-OFFNXT(G.FMT.02-CPP) project code style // NOLINTBEGIN(hicpp-signed-bitwise) @@ -112,10 +114,11 @@ bool Utf8ToUtf16LEByteCheck(const unsigned char *data, std::u16string &u16Str, s } case TWO_BYTES_STYLE1: case TWO_BYTES_STYLE2: { - uint8_t c2 = data[i + 1]; if (i + ONE_MORE_BYTE_TO_CONSUME >= inputSizeBytes) { return false; } + // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) + uint8_t c2 = data[i + 1]; i += ONE_MORE_BYTE_TO_CONSUME + 1; // NOLINTNEXTLINE(hicpp-signed-bitwise) uint32_t codePoint = ((c1 & LOWER_5_BITS_MASK) << UTF8_VALID_BITS) | (c2 & LOWER_6_BITS_MASK);