From 6c3a35a9f7ba40f68c962cdff32028b894cdc5d5 Mon Sep 17 00:00:00 2001 From: zhanghongyuan Date: Fri, 23 Oct 2026 05:53:43 +0800 Subject: [PATCH] fix: resolve QList out-of-bounds access in showDeviceInfo MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- deepin-devicemanager/src/Page/PageDetail.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deepin-devicemanager/src/Page/PageDetail.cpp b/deepin-devicemanager/src/Page/PageDetail.cpp index bf1c534e4..928d4b075 100644 --- a/deepin-devicemanager/src/Page/PageDetail.cpp +++ b/deepin-devicemanager/src/Page/PageDetail.cpp @@ -238,7 +238,7 @@ void PageDetail::showDeviceInfo(const QList &lstInfo) // 当添加到最后一个设备详细信息时,隐藏分隔符 if (device == lstInfo.last()) { // qCDebug(appLog) << "PageDetail::showDeviceInfo is last device, hide seperator"; - m_ListDetailSeperator[lstInfo.size() - 1]->setVisible(false); + m_ListDetailSeperator.last()->setVisible(false); } } // 刷新展示页面时,滚动条还原