Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Guard against missing list values #7747

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions runtime/executor/method.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -414,10 +414,14 @@ Error Method::parse_values() {
new (&values_[i]) EValue(t.get());
} break;
case executorch_flatbuffer::KernelTypes::TensorList: {
const auto items =
static_cast<const executorch_flatbuffer::TensorList*>(val)->items();
ET_CHECK_OR_RETURN_ERROR(
items != nullptr, InvalidProgram, "Missing list at index %zu", i);
// get list of serialization tensors and allocate storage for executor
// tensors
auto tensors = deserialization::parseTensorList(
static_cast<const executorch_flatbuffer::TensorList*>(val)->items(),
items,
values_,
n_value, // The size of the full array.
memory_manager_);
Expand All @@ -432,12 +436,15 @@ Error Method::parse_values() {
new (&values_[i]) EValue(tensors.get());
} break;
case executorch_flatbuffer::KernelTypes::OptionalTensorList: {
const auto items =
static_cast<const executorch_flatbuffer::OptionalTensorList*>(val)
->items();
ET_CHECK_OR_RETURN_ERROR(
items != nullptr, InvalidProgram, "Missing list at index %zu", i);
// Same as TensorList but optional<Tensor> instead of Tensor
auto tensors =
deserialization::parseListOptionalType<exec_aten::Tensor>(
static_cast<const executorch_flatbuffer::OptionalTensorList*>(
val)
->items(),
items,
values_,
n_value, // The size of the full array.
memory_manager_);
Expand Down
Loading