diff --git a/base/src/parcel.cpp b/base/src/parcel.cpp index 65b15f4ea1ed3e4b463f01753583a98ce433eeb6..1dfe9311cf8100a0406f9d4a82731b06ce7fb432 100644 --- a/base/src/parcel.cpp +++ b/base/src/parcel.cpp @@ -1044,7 +1044,7 @@ bool Parcel::ReadString16(std::u16string &value) } size_t readCapacity = (static_cast(dataLength) + 1) * sizeof(char16_t); - if (readCapacity <= GetReadableBytes()) { + if ((readCapacity > (static_cast(dataLength))) && (readCapacity <= GetReadableBytes())) { const uint8_t *str = ReadBuffer(readCapacity); if (str != nullptr) { const auto *u16Str = reinterpret_cast(str);