Skip to content

Commit

Permalink
Fix unsafe buffer usage warning (#114)
Browse files Browse the repository at this point in the history
PTAL

/cc @shiyi9801
  • Loading branch information
huningxin authored and shiyi9801 committed Feb 11, 2025
1 parent 961d1c0 commit 44a7c7f
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions services/webnn/ort/tensor_impl_ort.cc
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,11 @@ void TensorImplOrt::ReadTensorImpl(ReadTensorCallback callback) {
buffer_state->GetSharedLockedResource().tensor(),
&ort_tensor_raw_data));
CHECK(ort_tensor_raw_data);
mojo_base::BigBuffer output_buffer(
// SAFETY: ORT guarantees that it has allocated enough memory to
// store tensor.
mojo_base::BigBuffer output_buffer(UNSAFE_BUFFERS(
base::span(static_cast<const uint8_t*>(ort_tensor_raw_data),
bytes_to_read));
bytes_to_read)));

// Unlock the buffer contents.
std::move(completion_closure).Run();
Expand Down

0 comments on commit 44a7c7f

Please sign in to comment.