Skip to content

Commit cb8115f

Browse files
committed
fix: add null check for connection update
Added null pointer check before updating network connection settings to prevent potential crashes when the connection object is not found. This ensures the application handles missing connections gracefully by logging a warning and returning early instead of attempting to update a non-existent connection. Log: Fixed potential crash when updating non-existent network connections Influence: 1. Test network connection updates with valid and invalid UUIDs 2. Verify warning messages are logged for missing connections 3. Confirm application stability when connection objects are not found 4. Test that valid connection updates continue to work normally fix: 添加连接更新前的空指针检查 在更新网络连接设置前添加空指针检查,防止在连接对象未找到时出现潜在崩溃。 这确保应用程序能够优雅地处理缺失的连接,通过记录警告信息并提前返回,而不 是尝试更新不存在的连接。 Log: 修复更新不存在的网络连接时可能出现的崩溃问题 Influence: 1. 测试使用有效和无效UUID更新网络连接 2. 验证缺失连接时是否正确记录警告信息 3. 确认连接对象未找到时应用程序的稳定性 4. 测试有效的连接更新功能是否正常工作 PMS: BUG-303389
1 parent 80d039c commit cb8115f

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

net-view/operation/private/netmanagerthreadprivate.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1570,6 +1570,10 @@ void NetManagerThreadPrivate::doSetConnectInfo(const QString &id, NetType::NetIt
15701570
} else {
15711571
// 更新
15721572
connection = findConnectionByUuid(settings->uuid());
1573+
if (!connection) {
1574+
qCWarning(DNC) << "Update connection failed: connection not found for UUID" << settings->uuid();
1575+
return;
1576+
}
15731577
NMVariantMapMap finalSettings = settings->toMap();
15741578

15751579
QDBusPendingReply<> reply = connection->isUnsaved() ? connection->updateUnsaved(finalSettings) : connection->update(finalSettings);

0 commit comments

Comments
 (0)