From 41f1b57077ab8f325a186c5a51aca2dd48368c88 Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Tue, 3 Mar 2020 10:43:39 +0900 Subject: [PATCH] Fix GetByte method - Checks the result of bundle_get_byte() Change-Id: I4572060adc7cf1e6eebb149fbc68a2974add92b2 Signed-off-by: Hwankyu Jhun --- src/bundle_cpp.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/bundle_cpp.cc b/src/bundle_cpp.cc index 9f878e6..34c8a21 100644 --- a/src/bundle_cpp.cc +++ b/src/bundle_cpp.cc @@ -246,8 +246,13 @@ std::vector Bundle::GetStringArray(const std::string& key) const { std::vector 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(&bytes), &size); + if (ret != BUNDLE_ERROR_NONE) { + LOGE("bundle_get_byte() is failed"); + return {}; + } + return std::vector(bytes, bytes + size); } -- 2.7.4