mirror of
https://github.com/openharmony/ability_ability_runtime.git
synced 2026-08-24 22:21:36 -04:00
!19413 merge fix-leakobj-empty-check into master
fix: 防止GetDumpResult将空字符串赋值给dumpResult Created-by: denganliang Commit-by: denganliang Merged-by: openharmony_ci Description: ## 修改说明 - 防止 GetDumpResult 将 malloc 分配但内容为空字符串的 buf 赋值给 dumpResult - 根因:当 OHOS_GetMemLeakString malloc 分配了缓冲区但内容为空字符串时,原代码只判断 buf!=nullptr 就赋值 - 增加 *buf!=空字符 判断,与 buf!=nullptr 一起构成双重防御 **IssueNo**: https://gitcode.com/openharmony/hiviewdfx_hidumper/issues/586 ## 关联PR - openharmony/hiviewdfx_hidumper!767 ## 验证 - 编译通过 - 与 hidumper PR 配合验证 See merge request: openharmony/ability_ability_runtime!19413
This commit is contained in:
@@ -417,7 +417,7 @@ bool DumpRuntimeHelper::GetDumpResult(std::string &dumpResult)
|
||||
bool ret = func(TYPE_TXT, &buf, MEM_LEAK_MAX_SIZE);
|
||||
if (!ret) {
|
||||
TAG_LOGE(AAFwkTag::APPKIT, "TYPE_TXT Error");
|
||||
} else if (buf != nullptr) {
|
||||
} else if (buf != nullptr && *buf != '\0') {
|
||||
dumpResult = buf;
|
||||
TAG_LOGI(AAFwkTag::APPKIT, "TYPE_TXT finish, result:%{public}s", dumpResult.c_str());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user