mirror of
https://gitee.com/openharmony/telephony_core_service
synced 2024-11-27 02:00:45 +00:00
fix: fix string exception
Signed-off-by: liujiandong <liujiandong1@huawei.com>
This commit is contained in:
parent
b5c04c1bf8
commit
61e779cbc8
@ -519,7 +519,13 @@ std::string IccFile::ObtainValidLanguage(const std::string &langData)
|
||||
TELEPHONY_LOGE("data is nullptr!!");
|
||||
return "";
|
||||
}
|
||||
TELEPHONY_LOGI("ObtainValidLanguage all is %{public}s---%{public}d", data, langDataLen);
|
||||
|
||||
int dataLen = static_cast<int>(strlen(reinterpret_cast<char *>(data)));
|
||||
TELEPHONY_LOGI("ObtainValidLanguage all is %{public}s---%{public}d, dataLen:%{public}d",
|
||||
data, langDataLen, dataLen);
|
||||
if (langDataLen > dataLen) {
|
||||
langDataLen = dataLen;
|
||||
}
|
||||
for (int i = 0; (i + 1) < langDataLen; i += DATA_STEP) {
|
||||
std::string langName((char *)data, i, DATA_STEP);
|
||||
TELEPHONY_LOGI("ObtainValidLanguage item is %{public}d--%{public}s", i, langName.c_str());
|
||||
|
@ -2801,6 +2801,8 @@ HWTEST_F(BranchTest, Telephony_IccFile_002, Function | MediumTest | Level1) {
|
||||
EXPECT_EQ(iccId, "2143BA65FT");
|
||||
std::string langData = "";
|
||||
EXPECT_EQ(iccFile->ObtainValidLanguage(langData), "");
|
||||
langData = "000011286F050400000000010203FF";
|
||||
EXPECT_EQ(iccFile->ObtainValidLanguage(langData), "");
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user