Skip to content

Commit 03ed98b

Browse files
Guard nil asset.contentURL in ETCoreMLModel initWithAsset:
Differential Revision: D108334793 Pull Request resolved: pytorch#20338
1 parent 0e8c146 commit 03ed98b

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

backends/apple/coreml/runtime/delegate/ETCoreMLModel.mm

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,15 @@ - (nullable instancetype)initWithAsset:(ETCoreMLAsset *)asset
194194
return nil;
195195
}
196196

197-
MLModel *mlModel = [MLModel modelWithContentsOfURL:asset.contentURL
197+
NSURL *contentURL = asset.contentURL;
198+
if (contentURL == nil) {
199+
ETCoreMLLogErrorAndSetNSError(error,
200+
ETCoreMLErrorCorruptedModel,
201+
"asset.contentURL is nil");
202+
return nil;
203+
}
204+
205+
MLModel *mlModel = [MLModel modelWithContentsOfURL:contentURL
198206
configuration:configuration
199207
error:error];
200208
if (!mlModel) {

0 commit comments

Comments
 (0)