Skip to content

fix(image): ignore empty async image provider paths#455

Merged
wyu71 merged 1 commit into
linuxdeepin:masterfrom
wyu71:master
Jul 13, 2026
Merged

fix(image): ignore empty async image provider paths#455
wyu71 merged 1 commit into
linuxdeepin:masterfrom
wyu71:master

Conversation

@wyu71

@wyu71 wyu71 commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Skip image decoding when the parsed provider path is empty. 解析后的图片 Provider 路径为空时跳过解码。

Log: 避免异步图片请求打开空文件名
Influence: 异步图片加载异常路径

Skip image decoding when the parsed provider path is empty.
解析后的图片 Provider 路径为空时跳过解码。

Log: 避免异步图片请求打开空文件名
Influence: 异步图片加载异常路径

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @wyu71, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

★ 总体评分:100分

■ 【总体评价】

代码通过增加路径非空校验修复了潜在的空指针或越界异常,逻辑严谨且防御性良好。
修复了核心崩溃风险,代码质量高,无安全漏洞,故给予满分。

■ 【详细分析】

  • 1.语法逻辑(基本正确)✓

补丁在 AsyncImageResponse::run 函数中,parseProviderID 执行后增加了对 tempPath.isEmpty() 的判断。若路径为空,则发送 finished() 信号并提前 return,有效阻止了空路径传递给后续的 imageCache.get 函数,避免了可能的空指针解引用或越界异常。
潜在问题:无
建议:无

  • 2.代码质量(良好)✓

修复代码简洁明了,符合防御性编程规范。提前返回的逻辑清晰,没有引入冗余代码,与原有代码风格保持一致。
潜在问题:无
建议:无

  • 3.代码性能(无性能问题)✓

增加的 isEmpty() 判断为常数时间操作,开销极小。提前返回避免了无效的缓存查询和图片加载流程,在异常路径下提升了处理效率。
潜在问题:无
建议:无

  • 4.代码安全(存在0个安全漏洞)✓

漏洞对比统计:新增漏洞 0 个,减少漏洞 1 个,持平 0 个
原代码在路径为空时继续执行可能导致程序崩溃,属于拒绝服务漏洞。本次补丁通过提前返回修复了该问题,当前代码不存在安全漏洞。

  • 建议:无

■ 【改进建议代码示例】

--- a/src/src/imagedata/imageprovider.cpp
+++ b/src/src/imagedata/imageprovider.cpp
@@ -152,6 +152,10 @@ void AsyncImageResponse::run()
     QString tempPath;
     int frameIndex;
     parseProviderID(providerId, tempPath, frameIndex);
+    if (tempPath.isEmpty()) {
+        emit finished();
+        return;
+    }
 
     // 判断缓存中是否存在图片
     image = provider->imageCache.get(tempPath, frameIndex);

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: pengfeixx, wyu71

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@wyu71
wyu71 merged commit dfa3ff2 into linuxdeepin:master Jul 13, 2026
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants