Fix static analysis issue 73/317573/1
authorJihoi Kim <jihoi.kim@samsung.com>
Fri, 3 Jan 2025 06:29:48 +0000 (15:29 +0900)
committerJihoi Kim <jihoi.kim@samsung.com>
Fri, 3 Jan 2025 06:29:48 +0000 (15:29 +0900)
- Fix COMPARE_RESULT_OF_NEW
- Using std::nothrow when allocate object

Change-Id: I85196db63f6e60fb802022f1665511effc20688d
Signed-off-by: Jihoi Kim <jihoi.kim@samsung.com>
src/lib/request/request.cc

index 3fc18f7654d29d49748f6d7fc37ff29fd0546f96..fdea5a044b9e508226bde79fa48a049ee964f65d 100644 (file)
@@ -108,10 +108,14 @@ Request::Builder& Request::Builder::SetTimeout(unsigned int timeout) {
 }
 
 std::shared_ptr<Request> Request::Builder::Build() {
-  auto req =
-      std::shared_ptr<Request>(new Request(pid_, uid_, cmd_, opt_));
+  auto req = std::shared_ptr<Request>(
+      new (std::nothrow) Request(pid_, uid_, cmd_, opt_));
   std::string start_time;
   timespec start{};
+
+  if (req == nullptr)
+    return nullptr;
+
   if (b_ != nullptr)
     start_time = b_->GetString(AUL_K_STARTTIME);