fix: add blur radius limit to prevent shadow crash#646
Conversation
1. Add blur radius validation in doBoxShdowBlur to return early when radius exceeds 100 2. Add blur radius pre-check in getRawShadow to reject invalid values before processing 3. Prevent potential memory crash caused by excessively large shadow blur radius values Log: Added shadow blur radius limit to prevent application crash Influence: 1. Test shadow rendering with various blur radius values (0, 1, 99, 100, 101) 2. Verify normal shadow display with radius within valid range (2-100) 3. Test edge cases: negative radius, radius=0, radius=1 4. Verify application stability when providing invalid radius values 5. Check performance impact with radius at maximum allowed value (100) fix: 添加阴影模糊半径限制,防止崩溃 1. 在 doBoxShdowBlur 中添加半径超过100的早期返回处理 2. 在 getRawShadow 中添加阴影模糊半径的预处理检查,拒绝无效值 3. 防止因过大的阴影模糊半径值导致的内存崩溃 Log: 新增阴影模糊半径限制,防止应用崩溃 Influence: 1. 测试不同模糊半径值(0, 1, 99, 100, 101)下的阴影渲染 2. 验证有效范围内(2-100)阴影显示正常 3. 测试边界情况:负值半径、半径为0、半径为1 4. 验证使用无效半径值时应用程序的稳定性 5. 检查当半径设为最大值100时的性能影响
There was a problem hiding this comment.
Sorry @18202781743, you have reached your weekly rate limit of 500000 diff characters.
Please try again later or upgrade to continue using Sourcery
deepin pr auto review★ 总体评分:100分■ 【总体评价】
■ 【详细分析】
■ 【改进建议代码示例】 // 当前代码已完美修复安全问题,无需额外修改,保持现状即可
static inline void doBoxShdowBlur(QImage &image, int radius, const QRect &rect = QRect())
{
if (radius < 2 || radius > 100) {
return;
}
// ... 后续模糊处理逻辑
}
ShadowImage *DQuickShadowProvider::getRawShadow(const ShadowConfig &config)
{
// ... 前置校验逻辑 ...
// 限制 blurRadius 在合理范围内,防止异常值导致内存崩溃
if (Q_UNLIKELY(config.blurRadius < 0 || config.blurRadius > 100)) {
return nullptr;
}
ShadowImage *image = this->cache.value(config);
if (Q_LIKELY(image))
return image;
// ... 后续生成阴影逻辑 ...
} |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: 18202781743, BLumia The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
radius exceeds 100
before processing
blur radius values
Log: Added shadow blur radius limit to prevent application crash
Influence:
100, 101)
fix: 添加阴影模糊半径限制,防止崩溃
Log: 新增阴影模糊半径限制,防止应用崩溃
Influence: