diff --git a/backends/apple/coreml/runtime/delegate/ETCoreMLModel.mm b/backends/apple/coreml/runtime/delegate/ETCoreMLModel.mm index d4d2b584821..206714768b1 100644 --- a/backends/apple/coreml/runtime/delegate/ETCoreMLModel.mm +++ b/backends/apple/coreml/runtime/delegate/ETCoreMLModel.mm @@ -194,7 +194,15 @@ - (nullable instancetype)initWithAsset:(ETCoreMLAsset *)asset return nil; } - MLModel *mlModel = [MLModel modelWithContentsOfURL:asset.contentURL + NSURL *contentURL = asset.contentURL; + if (contentURL == nil) { + ETCoreMLLogErrorAndSetNSError(error, + ETCoreMLErrorCorruptedModel, + "asset.contentURL is nil"); + return nil; + } + + MLModel *mlModel = [MLModel modelWithContentsOfURL:contentURL configuration:configuration error:error]; if (!mlModel) {