mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-05-14 20:48:00 +00:00
Fix possible leak of OrtValue in initializer. There was a possible early return before ownership was transferred to the internal C++ Ort::Value.
29 lines
975 B
Objective-C
29 lines
975 B
Objective-C
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
// Licensed under the MIT License.
|
|
|
|
#import "ort_value.h"
|
|
|
|
#import "cxx_api.h"
|
|
|
|
NS_ASSUME_NONNULL_BEGIN
|
|
|
|
@interface ORTValue ()
|
|
|
|
/**
|
|
* Creates a value from an existing C++ API Ort::Value and takes ownership from it.
|
|
* Note: Ownership is guaranteed to be transferred on success but not otherwise.
|
|
*
|
|
* @param existingCXXAPIOrtValue The existing C++ API Ort::Value.
|
|
* @param externalTensorData Any external tensor data referenced by `existingCXXAPIOrtValue`.
|
|
* @param error Optional error information set if an error occurs.
|
|
* @return The instance, or nil if an error occurs.
|
|
*/
|
|
- (nullable instancetype)initWithCXXAPIOrtValue:(Ort::Value&&)existingCXXAPIOrtValue
|
|
externalTensorData:(nullable NSMutableData*)externalTensorData
|
|
error:(NSError**)error NS_DESIGNATED_INITIALIZER;
|
|
|
|
- (Ort::Value&)CXXAPIOrtValue;
|
|
|
|
@end
|
|
|
|
NS_ASSUME_NONNULL_END
|