Skip to content

fix: resolve QList out-of-bounds access in showDeviceInfo - #869

Merged
deepin-bot[bot] merged 1 commit into
linuxdeepin:masterfrom
add-uos:agent/pms-bug-bot/68abf749a8d4
Oct 26, 2026
Merged

deepin-bot[bot] merged 1 commit into
linuxdeepin:masterfrom
add-uos:agent/pms-bug-bot/68abf749a8d4

Conversation

@add-uos

@add-uos add-uos commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

fix: resolve QList out-of-bounds access in showDeviceInfo

  1. Root cause: when lstInfo contains nullptr entries, the nullptr
    filter skips them without calling addWidgets(), but the separator
    index used lstInfo.size()-1 instead of the actual separator count
  2. Fix: replace m_ListDetailSeperator[lstInfo.size()-1] with
    m_ListDetailSeperator.last() since addWidgets() just appended it
  3. Impact: prevents crash when device list mixes nullptr and valid
    devices, no behavior change for all-valid-device lists

Log: Fixed crash when device list contains null entries

Influence:

  1. Test device detail view with mixed null and valid device entries
  2. Verify no crash when device list contains nullptr items
  3. Test device detail view with all-valid-device list for regression

fix: 修复showDeviceInfo中QList越界访问导致崩溃

  1. 根因:当设备列表lstInfo包含nullptr项时,空指针过滤跳过这些项
    不调用addWidgets(),但分隔符索引仍使用lstInfo.size()-1而非
    实际分隔符数量,导致越界访问
  2. 方案:将m_ListDetailSeperator[lstInfo.size()-1]替换为
    m_ListDetailSeperator.last(),因为addWidgets()刚追加了该分隔符
  3. 影响:防止设备列表混有nullptr和有效设备时的崩溃,对全有效设备
    列表无行为变化

Log: 修复设备列表包含空指针项时设备详情页崩溃的问题

Influence:

  1. 测试设备列表混有空指针和有效设备时设备详情页显示
  2. 验证设备列表包含nullptr项时不崩溃
  3. 测试全有效设备列表场景确认无回归

PMS: BUG-DM-DEF-001

Summary by Sourcery

Bug Fixes:

  • Prevent a crash in the device details view when the device list contains null entries alongside valid devices.

1. Root cause: when lstInfo contains nullptr entries, the nullptr
   filter skips them without calling addWidgets(), but the separator
   index used lstInfo.size()-1 instead of the actual separator count
2. Fix: replace m_ListDetailSeperator[lstInfo.size()-1] with
   m_ListDetailSeperator.last() since addWidgets() just appended it
3. Impact: prevents crash when device list mixes nullptr and valid
   devices, no behavior change for all-valid-device lists

Log: Fixed crash when device list contains null entries

Influence:
1. Test device detail view with mixed null and valid device entries
2. Verify no crash when device list contains nullptr items
3. Test device detail view with all-valid-device list for regression

fix: 修复showDeviceInfo中QList越界访问导致崩溃

1. 根因:当设备列表lstInfo包含nullptr项时,空指针过滤跳过这些项
   不调用addWidgets(),但分隔符索引仍使用lstInfo.size()-1而非
   实际分隔符数量,导致越界访问
2. 方案:将m_ListDetailSeperator[lstInfo.size()-1]替换为
   m_ListDetailSeperator.last(),因为addWidgets()刚追加了该分隔符
3. 影响:防止设备列表混有nullptr和有效设备时的崩溃,对全有效设备
   列表无行为变化

Log: 修复设备列表包含空指针项时设备详情页崩溃的问题

Influence:
1. 测试设备列表混有空指针和有效设备时设备详情页显示
2. 验证设备列表包含nullptr项时不崩溃
3. 测试全有效设备列表场景确认无回归

PMS: BUG-DM-DEF-001
@sourcery-ai

sourcery-ai Bot commented Oct 22, 2026

Copy link
Copy Markdown

Sorry @add-uos, you've used your own review budget of 250,000 diff characters for the last 7 days.

You can request another review in 5 days and 7 hours by commenting @sourcery-ai review. Upgrade to get a review now.

@sourcery-ai

sourcery-ai Bot commented Oct 22, 2026

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Fixes a crash in showDeviceInfo when null and valid device entries are mixed by targeting the separator actually appended for the last valid device, while preserving behavior for lists containing only valid devices.

Sequence diagram for safe device detail rendering

sequenceDiagram
    participant PageDetail
    participant DeviceList as DeviceList
    participant Separators as Separators

    PageDetail->>DeviceList: showDeviceInfo(lstInfo)
    loop each device
        alt device is nullptr
            PageDetail->>PageDetail: skip device
        else device is valid
            PageDetail->>PageDetail: addWidgets()
            PageDetail->>Separators: last()->setVisible(false)
        end
    end
Loading

File-Level Changes

Change Details Files
Use the most recently appended separator when hiding the separator after the last valid device.
  • Replace the list-size-based separator index with QList::last().
  • Ensure null device entries skipped by the filter cannot cause an out-of-bounds separator access.
deepin-devicemanager/src/Page/PageDetail.cpp

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

🤖 AI 代码审查报告

总体评分: 100 分 (通过阈值: 70分)

Pass


📊 总体评价

项目 结果
审查结论 代码审查通过
评分详情 本次提交修复了 showDeviceInfo 函数中 QList 越界访问问题,将基于 lstInfo.size() 的索引访问替换为 .last() 方法,逻辑正确、改动最小化、无安全风险。四维度均无问题,启发式扫描与 OCR 审查亦未发现问题。

🔍 详细分析

1. 语法逻辑 ✅

评价: 语法正确,逻辑清晰 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: []


2. 代码质量 ✅

评价: 代码结构清晰,注释完整 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: []


3. 代码性能 ✅

评价: 性能良好,资源使用合理 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: []


4. 代码安全 🔒

评价: 存在0个安全漏洞 ✅ 通过

🔐 发现 0 个安全漏洞

安全漏洞详情:
✅ 未发现安全漏洞

建议: []


💡 改进建议代码示例


本报告由 AI 代码审查工具自动生成

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: add-uos, lzwind

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

@add-uos

add-uos commented Oct 26, 2026

Copy link
Copy Markdown
Contributor Author

/merge

@deepin-bot
deepin-bot Bot merged commit 3155f2b into linuxdeepin:master Oct 26, 2026
17 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