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/AndroidKeymaster41Device.cpp b/ng/AndroidKeymaster41Device.cpp
index c360ff2..e9abb9e 100644
--- a/ng/AndroidKeymaster41Device.cpp
+++ b/ng/AndroidKeymaster41Device.cpp
@@ -35,7 +35,7 @@
} // namespace
IKeymasterDevice* CreateKeymasterDevice(SecurityLevel securityLevel) {
- return new AndroidKeymaster41Device(securityLevel);
+ return new (std::nothrow) AndroidKeymaster41Device(securityLevel);
}
Return<V41ErrorCode>