From: Hwankyu Jhun Date: Tue, 2 Apr 2024 05:42:10 +0000 (+0900) Subject: Fix preference_get_string() function X-Git-Tag: accepted/tizen/unified/20240403.095032~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5b16f9e4f28a5d1f5fb339756a177f13cc6eb32f;p=platform%2Fcore%2Fapi%2Fpreference.git Fix preference_get_string() function In the previous implementation, the preference does not write the data if the string value is empty string. Even if the data length is 0, the function should return the empty string. This patch is for backward compatibility. Change-Id: I36c9892cda0530fc3a2170e73c685958d188232b Signed-off-by: Hwankyu Jhun --- diff --git a/preference/file-internal.cc b/preference/file-internal.cc index cf250ed..a46ddc1 100644 --- a/preference/file-internal.cc +++ b/preference/file-internal.cc @@ -114,13 +114,8 @@ std::unique_ptr File::GetData() { Data::Type data_type = static_cast(type); if (data_type == Data::Type::STRING) { - if (index == raw_data_.size()) - return nullptr; - - if (raw_data_[raw_data_.size() - 1] != '\0') { - _W("Last character is not a null-terminated string"); + if (index == raw_data_.size() || raw_data_[raw_data_.size() - 1] != '\0') raw_data_.push_back(0x00); - } const char* str = reinterpret_cast(&raw_data_[index]); data->SetString(str);