diff options
Diffstat (limited to 'ng/AndroidKeymaster3Device.cpp')
-rw-r--r-- | ng/AndroidKeymaster3Device.cpp | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/ng/AndroidKeymaster3Device.cpp b/ng/AndroidKeymaster3Device.cpp index 5ab1739..8c17f69 100644 --- a/ng/AndroidKeymaster3Device.cpp +++ b/ng/AndroidKeymaster3Device.cpp @@ -85,7 +85,7 @@ inline keymaster_tag_type_t typeFromTag(const keymaster_tag_t tag) { class KmParamSet : public keymaster_key_param_set_t { public: explicit KmParamSet(const hidl_vec<KeyParameter>& keyParams) { - params = new keymaster_key_param_t[keyParams.size()]; + params = new (std::nothrow) keymaster_key_param_t[keyParams.size()]; length = keyParams.size(); for (size_t i = 0; i < keyParams.size(); ++i) { auto tag = legacy_enum_conversion(keyParams[i].tag); @@ -220,9 +220,9 @@ void addClientAndAppData(const hidl_vec<uint8_t>& clientId, const hidl_vec<uint8 } // anonymous namespace AndroidKeymaster3Device::AndroidKeymaster3Device() - : impl_(new ::keymaster::AndroidKeymaster( - []() -> auto { - auto context = new PureSoftKeymasterContext(KmVersion::KEYMASTER_3); + : impl_(new (std::nothrow)::keymaster::AndroidKeymaster( + []() -> auto{ + auto context = new (std::nothrow) PureSoftKeymasterContext(KmVersion::KEYMASTER_3); context->SetSystemVersion(GetOsVersion(), GetOsPatchlevel()); context->SetVendorPatchlevel(GetVendorPatchlevel()); // Software devices cannot be configured by the boot loader but they have @@ -237,7 +237,8 @@ AndroidKeymaster3Device::AndroidKeymaster3Device() AndroidKeymaster3Device::AndroidKeymaster3Device(KeymasterContext* context, KeymasterHardwareProfile profile) - : impl_(new ::keymaster::AndroidKeymaster(context, kOperationTableSize)), profile_(profile) {} + : impl_(new (std::nothrow)::keymaster::AndroidKeymaster(context, kOperationTableSize)), + profile_(profile) {} AndroidKeymaster3Device::~AndroidKeymaster3Device() {} @@ -504,20 +505,22 @@ Return<ErrorCode> AndroidKeymaster3Device::abort(uint64_t operationHandle) { } IKeymasterDevice* CreateKeymasterDevice() { - return new AndroidKeymaster3Device(); + return new (std::nothrow) AndroidKeymaster3Device(); } IKeymasterDevice* CreateKeymasterDevice(keymaster2_device_t* km2_device) { if (ConfigureDevice(km2_device) != KM_ERROR_OK) return nullptr; - auto context = new Keymaster2PassthroughContext(KmVersion::KEYMASTER_3, km2_device); + auto context = + new (std::nothrow) Keymaster2PassthroughContext(KmVersion::KEYMASTER_3, km2_device); context->SetSystemVersion(GetOsVersion(), GetOsPatchlevel()); - return new AndroidKeymaster3Device(context, KeymasterHardwareProfile::KM2); + return new (std::nothrow) AndroidKeymaster3Device(context, KeymasterHardwareProfile::KM2); } IKeymasterDevice* CreateKeymasterDevice(keymaster1_device_t* km1_device) { - auto context = new Keymaster1PassthroughContext(KmVersion::KEYMASTER_3, km1_device); + auto context = + new (std::nothrow) Keymaster1PassthroughContext(KmVersion::KEYMASTER_3, km1_device); context->SetSystemVersion(GetOsVersion(), GetOsPatchlevel()); - return new AndroidKeymaster3Device(context, KeymasterHardwareProfile::KM1); + return new (std::nothrow) AndroidKeymaster3Device(context, KeymasterHardwareProfile::KM1); } } // namespace ng |