| 141 | } |
| 142 | |
| 143 | std::unique_ptr<ByteData> DecodeStream::readByteData() { |
| 144 | auto length = readEncodedUint32(); |
| 145 | auto bytes = readBytes(length); |
| 146 | // must check whether the byte data is valid. otherwise, memcpy() will crash. |
| 147 | if (length == 0 || length > bytes.length() || context->hasException()) { |
| 148 | return nullptr; |
| 149 | } |
| 150 | return ByteData::MakeCopy(bytes.data(), length); |
| 151 | } |
| 152 | |
| 153 | std::string DecodeStream::readUTF8String() { |
| 154 | if (_position < dataView.size()) { |
no test coverage detected