!38883 【bug】解决realPath返回nullptr提前return问题

Merge pull request !38883 from 吴寅潇/fixRealPathPro
This commit is contained in:
openharmony_ci 2024-07-26 03:34:38 +00:00 committed by Gitee
commit 2fbb08a791
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F

View File

@ -319,17 +319,13 @@ std::shared_ptr<RSData> FileImageLoader::LoadImageData(
return nullptr;
}
char realPath[PATH_MAX] = { 0x00 };
if (realpath(filePath.c_str(), realPath) == nullptr) {
TAG_LOGW(AceLogTag::ACE_IMAGE, "realpath fail! filePath: %{public}s, fail reason: %{public}s src:%{public}s",
filePath.c_str(), strerror(errno), src.c_str());
return nullptr;
}
realpath(filePath.c_str(), realPath);
auto result = SkData::MakeFromFileName(realPath);
if (!result) {
TAG_LOGW(AceLogTag::ACE_IMAGE,
"read data failed, filePath: %{public}s, src: %{public}s, fail reason: "
"read data failed, filePath: %{public}s, realPath: %{public}s, src: %{public}s, fail reason: "
"%{public}s",
filePath.c_str(), src.c_str(), strerror(errno));
filePath.c_str(), src.c_str(), realPath, strerror(errno));
}
#ifndef USE_ROSEN_DRAWING
#ifdef PREVIEW