Use new (std::nothrow) throughout
If code uses "normal" `new`, the compiler is allowed to assume that
`nullptr` is never returned, even if built with -fno-exceptions.
Use `new (std::nothrow)` throughout so that `nullptr` gets returned
and can (in some cases) be handled.
Bug: 215451239
Test: VtsAidlKeyMintTargetTest
Ignore-AOSP-First: Cherry pick from AOSP
Change-Id: Ied97ce946c0fbfbd5449c533e7ce1acbd0f595c5
(cherry picked from commit b80ef359b047a6bb72947b582102a979568f5c30)
diff --git a/ng/AndroidSharedSecret.cpp b/ng/AndroidSharedSecret.cpp
index 0ae3d2d..b2cb85d 100644
--- a/ng/AndroidSharedSecret.cpp
+++ b/ng/AndroidSharedSecret.cpp
@@ -44,7 +44,8 @@
ScopedAStatus AndroidSharedSecret::computeSharedSecret(const vector<SharedSecretParameters>& params,
vector<uint8_t>* sharingCheck) {
ComputeSharedHmacRequest request(impl_->message_version());
- request.params_array.params_array = new keymaster::HmacSharingParameters[params.size()];
+ request.params_array.params_array =
+ new (std::nothrow) keymaster::HmacSharingParameters[params.size()];
request.params_array.num_params = params.size();
for (size_t i = 0; i < params.size(); ++i) {
request.params_array.params_array[i].seed = {params[i].seed.data(), params[i].seed.size()};