@@ -415,10 +415,14 @@ Error Method::parse_values() {
415415 new (&values_[i]) EValue (t.get ());
416416 } break ;
417417 case executorch_flatbuffer::KernelTypes::TensorList: {
418+ const auto items =
419+ static_cast <const executorch_flatbuffer::TensorList*>(val)->items ();
420+ ET_CHECK_OR_RETURN_ERROR (
421+ items != nullptr , InvalidProgram, " Missing list at index %zu" , i);
418422 // get list of serialization tensors and allocate storage for executor
419423 // tensors
420424 auto tensors = deserialization::parseTensorList (
421- static_cast < const executorch_flatbuffer::TensorList*>(val)-> items () ,
425+ items,
422426 values_,
423427 n_value, // The size of the full array.
424428 memory_manager_);
@@ -433,12 +437,15 @@ Error Method::parse_values() {
433437 new (&values_[i]) EValue (tensors.get ());
434438 } break ;
435439 case executorch_flatbuffer::KernelTypes::OptionalTensorList: {
440+ const auto items =
441+ static_cast <const executorch_flatbuffer::OptionalTensorList*>(val)
442+ ->items ();
443+ ET_CHECK_OR_RETURN_ERROR (
444+ items != nullptr , InvalidProgram, " Missing list at index %zu" , i);
436445 // Same as TensorList but optional<Tensor> instead of Tensor
437446 auto tensors =
438447 deserialization::parseListOptionalType<exec_aten::Tensor>(
439- static_cast <const executorch_flatbuffer::OptionalTensorList*>(
440- val)
441- ->items (),
448+ items,
442449 values_,
443450 n_value, // The size of the full array.
444451 memory_manager_);
0 commit comments