Skip to content

Commit b13041a

Browse files
committed
fix: prevent crash when default sink name is empty
Fixed a potential crash in SoundController::existActiveOutputDevice() when checking for active output devices. The method was accessing m_defaultSinkInter->name() without verifying that the name string is not empty, which could lead to undefined behavior when calling startsWith() or contains() on an empty string. Added an additional check `&& !m_defaultSinkInter->name().isEmpty()` to ensure the name string is not empty before performing string operations. This prevents potential crashes in cloud platform environments where sound device names might be empty. Log: Fixed a crash that could occur when checking for active sound output devices Influence: 1. Test sound output device detection in normal desktop environments 2. Test in cloud platform environments where sound devices may have empty names 3. Verify that the sound dock plugin doesn't crash when no active output devices are available 4. Test with various sound device configurations including Bluetooth devices 5. Verify that the sound indicator shows correct status for all device types fix: 修复默认音频输出设备名称为空时可能导致的崩溃问题 修复了SoundController::existActiveOutputDevice()方法中检查活动输出设备时 可能出现的崩溃问题。该方法在访问m_defaultSinkInter->name()时没有验证名称 字符串是否为空,这可能导致在空字符串上调用startsWith()或contains()时出现 未定义行为。 添加了额外的检查`&& !m_defaultSinkInter->name().isEmpty()`,确保在执行字 符串操作前名称字符串不为空。这可以防止在云平台环境中音频设备名称可能为空 时出现潜在崩溃。 Log: 修复了检查活动音频输出设备时可能出现的崩溃问题 Influence: 1. 在正常桌面环境中测试音频输出设备检测 2. 在云平台环境中测试音频设备名称为空的情况 3. 验证音频坞站插件在没有活动输出设备时不会崩溃 4. 测试包括蓝牙设备在内的各种音频设备配置 5. 验证音频指示器对所有设备类型显示正确的状态 PMS: BUG-345945
1 parent 0329379 commit b13041a

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

plugins/dde-dock/sound/soundcontroller.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,5 +121,5 @@ bool SoundController::existActiveOutputDevice() const
121121
}
122122
}
123123
// 兼容云平台无端口的情况
124-
return SoundModel::ref().ports().isEmpty() && m_defaultSinkInter && !m_defaultSinkInter->name().startsWith("auto_null") && !m_defaultSinkInter->name().contains("bluez");
124+
return SoundModel::ref().ports().isEmpty() && m_defaultSinkInter && !m_defaultSinkInter->name().startsWith("auto_null") && !m_defaultSinkInter->name().contains("bluez") && !m_defaultSinkInter->name().isEmpty();
125125
}

0 commit comments

Comments
 (0)