Fix GetByte method 47/226447/1
authorHwankyu Jhun <h.jhun@samsung.com>
Tue, 3 Mar 2020 01:43:39 +0000 (10:43 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Tue, 3 Mar 2020 01:43:39 +0000 (10:43 +0900)
- Checks the result of bundle_get_byte()

Change-Id: I4572060adc7cf1e6eebb149fbc68a2974add92b2
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
src/bundle_cpp.cc

index 9f878e6..34c8a21 100644 (file)
@@ -246,8 +246,13 @@ std::vector<std::string> Bundle::GetStringArray(const std::string& key) const {
 std::vector<unsigned char> Bundle::GetByte(const std::string& key) const {
   size_t size;
   unsigned char* bytes = nullptr;
-  bundle_get_byte(impl_->handle_, key.c_str(),
+  int ret = bundle_get_byte(impl_->handle_, key.c_str(),
       reinterpret_cast<void**>(&bytes), &size);
+  if (ret != BUNDLE_ERROR_NONE) {
+    LOGE("bundle_get_byte() is failed");
+    return {};
+  }
+
   return std::vector<unsigned char>(bytes, bytes + size);
 }