Skip to content
Merged
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
13 changes: 13 additions & 0 deletions runtime/executor/tensor_parser_portable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,19 @@ Result<Tensor> parseTensor(
sizes = const_cast<exec_aten::SizesType*>(serialized_sizes);
dim_order = const_cast<exec_aten::DimOrderType*>(serialized_dim_order);
}
// Validate sizes before using them in case the PTE data is bad. We can't
// detect bad positive values, but we can reject negative values, which would
// otherwise panic in the TensorImpl ctor. dim_order_to_stride() will validate
// dim_order.
for (int i = 0; i < dim; i++) {
ET_CHECK_OR_RETURN_ERROR(
sizes[i] >= 0,
InvalidProgram,
"Negative size[%d] %" PRId32,
i,
sizes[i]);
}

// We will remove strides from schema.
// Allocating strides buffer here and populating it.
// In subsequent diffs we can remove strides accessor, however this
Expand Down