| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2016 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include <memory> |
| 6 #include <string> |
| 7 |
| 8 #include "src/unicode-decoder.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 |
| 11 namespace v8 { |
| 12 namespace internal { |
| 13 |
| 14 namespace { |
| 15 |
| 16 using Utf8Decoder = unibrow::Utf8Decoder<512>; |
| 17 |
| 18 void Decode(Utf8Decoder* decoder, const std::string& str) { |
| 19 // Put the string in its own buffer on the heap to make sure that |
| 20 // AddressSanitizer's heap-buffer-overflow logic can see what's going on. |
| 21 std::unique_ptr<char[]> buffer(new char[str.length()]); |
| 22 memcpy(buffer.get(), str.data(), str.length()); |
| 23 decoder->Reset(buffer.get(), str.length()); |
| 24 } |
| 25 |
| 26 } // namespace |
| 27 |
| 28 TEST(UnicodeTest, ReadOffEndOfUtf8String) { |
| 29 Utf8Decoder decoder; |
| 30 |
| 31 // Not enough continuation bytes before string ends. |
| 32 Decode(&decoder, "\xE0"); |
| 33 Decode(&decoder, "\xED"); |
| 34 Decode(&decoder, "\xF0"); |
| 35 Decode(&decoder, "\xF4"); |
| 36 } |
| 37 |
| 38 } // namespace internal |
| 39 } // namespace v8 |
| OLD | NEW |