summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSung-hun Kim <sfoon.kim@samsung.com>2024-07-04 10:04:59 +0900
committerSung-hun Kim <sfoon.kim@samsung.com>2024-07-04 10:04:59 +0900
commit4b52310031e7a1849a74f298479782ed08840cc6 (patch)
treed583f8f72cf5f02f26e1c997100bb417088f1919
parent28d2ec4f084e41bc3983b3ae59317dc20cc1719b (diff)
downloadttrace-4b52310031e7a1849a74f298479782ed08840cc6.tar.gz
ttrace-4b52310031e7a1849a74f298479782ed08840cc6.tar.bz2
ttrace-4b52310031e7a1849a74f298479782ed08840cc6.zip
The new operator in C++ does not return nullptr when it is failed. Instead, it throws a bad_alloc exception to notify the failure. With an optional `std::nothrow` keyword, the new operator returns nullptr instead of exception throwing when it is failed. This patch fixes a svace issue 209972. Change-Id: I6a6f900f06bf7911fc9aa53366d5da6375680915 Signed-off-by: Sung-hun Kim <sfoon.kim@samsung.com>
-rwxr-xr-xatrace/atrace.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/atrace/atrace.cpp b/atrace/atrace.cpp
index a465be0..4d06845 100755
--- a/atrace/atrace.cpp
+++ b/atrace/atrace.cpp
@@ -757,8 +757,8 @@ static void dumpTrace(bool startup)
}
const size_t bufSize = 64*1024;
- std::unique_ptr<uint8_t[]> in(new uint8_t[bufSize]);
- std::unique_ptr<uint8_t[]> out(new uint8_t[bufSize]);
+ std::unique_ptr<uint8_t[]> in(new(std::nothrow) uint8_t[bufSize]);
+ std::unique_ptr<uint8_t[]> out(new(std::nothrow) uint8_t[bufSize]);
if ((in == nullptr) || (out == nullptr)) {
fprintf(stderr, "Could not allocate memory");
close(traceFD);