From: Sung-hun Kim Date: Thu, 4 Jul 2024 01:04:59 +0000 (+0900) Subject: atrace: Fix a svace issue X-Git-Tag: accepted/tizen/unified/20240704.173826^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fheads%2Faccepted%2Ftizen_unified_dev;p=tools%2Fttrace.git atrace: Fix a svace issue 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 --- 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 in(new uint8_t[bufSize]); - std::unique_ptr out(new uint8_t[bufSize]); + std::unique_ptr in(new(std::nothrow) uint8_t[bufSize]); + std::unique_ptr out(new(std::nothrow) uint8_t[bufSize]); if ((in == nullptr) || (out == nullptr)) { fprintf(stderr, "Could not allocate memory"); close(traceFD);