From 1b1df2d77099f4c0499ca3415fb99315cd203bda Mon Sep 17 00:00:00 2001 From: zhanghongyuan Date: Fri, 23 Oct 2026 03:58:50 +0800 Subject: [PATCH] fix: initialize m_FinishedGenerator MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. Root cause: m_FinishedGenerator declared without initializer in GenerateDevicePool.h, constructor does not zero it either 2. Fix: add C++11 in-class initializer to cover all construction paths, eliminating undefined behavior on early member access 3. Impact: no behavior change for existing call flow, only removes UB risk from reading uninitialized member before generateDevice() Influence: 1. Test device generation with normal workflow 2. Verify m_FinishedGenerator starts at zero after construction 3. Confirm slotFinished counter works correctly fix: 初始化 m_FinishedGenerator 成员变量 1. 根因:GenerateDevicePool.h 中 m_FinishedGenerator 声明无初始化器, 构造函数也未对其赋值 2. 方案:在声明处添加 C++11 类内初始化器,覆盖所有构造路径, 消除在 generateDevice() 调用前读取该成员的未定义行为 3. 影响:现有调用流程无行为变化,仅消除读取未初始化成员的 UB 风险 Influence: 1. 测试正常设备生成流程 2. 验证构造后 m_FinishedGenerator 初始值为零 3. 确认 slotFinished 计数器工作正常 --- deepin-devicemanager/src/GenerateDevice/GenerateDevicePool.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deepin-devicemanager/src/GenerateDevice/GenerateDevicePool.h b/deepin-devicemanager/src/GenerateDevice/GenerateDevicePool.h index 7fe9d03e4..9c581d4af 100644 --- a/deepin-devicemanager/src/GenerateDevice/GenerateDevicePool.h +++ b/deepin-devicemanager/src/GenerateDevice/GenerateDevicePool.h @@ -83,7 +83,7 @@ private slots: private: QList m_TypeList; - int m_FinishedGenerator; + int m_FinishedGenerator = 0; }; #endif // GENERATEDEVICEPOOL_H