Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(430)

Side by Side Diff: test/unittests/unicode-unittest.cc

Issue 2521933002: Merged: Fix out-of-range access in unibrow::Utf8::CalculateValue. (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « test/unittests/BUILD.gn ('k') | test/unittests/unittests.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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
OLDNEW
« no previous file with comments | « test/unittests/BUILD.gn ('k') | test/unittests/unittests.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698