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

Side by Side Diff: src/wasm/wasm-function-name-table.cc

Issue 1967023004: [wasm] Add UTF-8 validation (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: rebase on parallel compilation Created 4 years, 7 months 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 | « src/wasm/module-decoder.cc ('k') | src/wasm/wasm-module.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 the V8 project authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/wasm/wasm-function-name-table.h" 5 #include "src/wasm/wasm-function-name-table.h"
6 6
7 #include "src/wasm/wasm-module.h" 7 #include "src/wasm/wasm-module.h"
8 8
9 namespace v8 { 9 namespace v8 {
10 namespace internal { 10 namespace internal {
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 auto undefined = [&func_names_array]() -> Handle<Object> { 53 auto undefined = [&func_names_array]() -> Handle<Object> {
54 return func_names_array->GetIsolate()->factory()->undefined_value(); 54 return func_names_array->GetIsolate()->factory()->undefined_value();
55 }; 55 };
56 if (func_index >= num_funcs) return undefined(); 56 if (func_index >= num_funcs) return undefined();
57 int offset = func_names_array->get_int(func_index + 1); 57 int offset = func_names_array->get_int(func_index + 1);
58 int next_offset = func_index == num_funcs - 1 58 int next_offset = func_index == num_funcs - 1
59 ? func_names_array->length() 59 ? func_names_array->length()
60 : func_names_array->get_int(func_index + 2); 60 : func_names_array->get_int(func_index + 2);
61 ScopedVector<byte> buffer(next_offset - offset); 61 ScopedVector<byte> buffer(next_offset - offset);
62 func_names_array->copy_out(offset, buffer.start(), next_offset - offset); 62 func_names_array->copy_out(offset, buffer.start(), next_offset - offset);
63 if (!unibrow::Utf8::Validate(buffer.start(), buffer.length())) {
64 return undefined();
65 }
63 MaybeHandle<Object> maybe_name = 66 MaybeHandle<Object> maybe_name =
64 func_names_array->GetIsolate()->factory()->NewStringFromUtf8( 67 func_names_array->GetIsolate()->factory()->NewStringFromUtf8(
65 Vector<const char>::cast(buffer)); 68 Vector<const char>::cast(buffer));
66 return maybe_name.is_null() ? undefined() : maybe_name.ToHandleChecked(); 69 return maybe_name.is_null() ? undefined() : maybe_name.ToHandleChecked();
67 } 70 }
68 71
69 } // namespace wasm 72 } // namespace wasm
70 } // namespace internal 73 } // namespace internal
71 } // namespace v8 74 } // namespace v8
OLDNEW
« no previous file with comments | « src/wasm/module-decoder.cc ('k') | src/wasm/wasm-module.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698