Fix static analysis issue 72/317572/1
authorJihoi Kim <jihoi.kim@samsung.com>
Fri, 3 Jan 2025 06:36:39 +0000 (15:36 +0900)
committerJihoi Kim <jihoi.kim@samsung.com>
Fri, 3 Jan 2025 07:18:28 +0000 (16:18 +0900)
- Fix FORWARD_NULL
- Fix UNINIT_CTOR

Change-Id: I2c883caed16315b804a30a16fcee82716979a3e7
Signed-off-by: Jihoi Kim <jihoi.kim@samsung.com>
src/bundle/bundle_cpp.cc
src/parcel/parcel.cc

index c8396c4a7283c8db9beb8ea24e8781ceb33a0978..a73cf1fbd289dd0b0fe9cdd3c1a484d12b1dcda4 100644 (file)
@@ -481,9 +481,11 @@ std::vector<unsigned char> Bundle::GetByte(const std::string& key) const {
 
   auto& raw_values = key_info->GetValues();
   unsigned char* bytes = nullptr;
-  if (!raw_values.empty())
+  size_t size = 0;
+  if (!raw_values.empty()) {
     bytes = reinterpret_cast<unsigned char*>(raw_values[0].get());
-  auto size = reinterpret_cast<size_t>(key_info->GetValuesSize()[0]);
+    size = reinterpret_cast<size_t>(key_info->GetValuesSize()[0]);
+  }
   return std::vector<unsigned char>(bytes, bytes + size);
 }
 
index 7ad28b91d18abdafbf9b99d4b7bac3025256cdc0..63fbaefa642855989cca7e1d1955b8714ddb3532 100644 (file)
@@ -42,13 +42,9 @@ Parcel::Impl::Impl(Parcel* parent, size_t data_capacity, uint8_t* data)
     data_ = static_cast<uint8_t*>(malloc(data_capacity_));
 }
 
-Parcel::Impl::Impl(Parcel* parent, uint8_t* start_pos, size_t data_size) {
-  data_ = start_pos;
-  data_capacity_ = data_size;
-  data_size_ = 0;
-  ownership_ = false;
-  pin_ = true;
-}
+Parcel::Impl::Impl(Parcel* parent, uint8_t* start_pos, size_t data_size)
+    : parent_(parent), data_capacity_(data_size), data_size_(0),
+      data_(start_pos), ownership_(false), pin_(true) {}
 
 Parcel::Impl::~Impl() {
   if (ownership_) free(data_);