From 2c8f9c6c2323c99630e6dba553c45b6148876fbb Mon Sep 17 00:00:00 2001 From: Refuhr Date: Wed, 29 Jul 2026 16:17:40 +0200 Subject: [PATCH] fix: skip saved connections this build cannot create CanConFactory::create() returns nullptr for a type the platform does not support, and loadConnections() handed that straight to the model, which appends it to the connection list unguarded. Every later iteration over that list then dereferences it. Reachable by carrying a settings file holding a gs_usb connection from Windows to another platform, and by any saved type id the factory does not recognise. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01XZnuZJ7zc3e8hk6C8bGDZN --- connections/connectionwindow.cpp | 7 +++++++ ui/newconnectiondialog.ui | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/connections/connectionwindow.cpp b/connections/connectionwindow.cpp index 7f1ab68..bebfda4 100644 --- a/connections/connectionwindow.cpp +++ b/connections/connectionwindow.cpp @@ -580,6 +580,13 @@ void ConnectionWindow::loadConnections() for(int i = 0 ; i < portNames.count() ; i++) { CANConnection* conn_p = create((CANCon::type)devTypes[i], portNames[i], driverNames[i], serialSpeeds[i], busSpeeds[i], isCanFds[i] ? true : false, DataRates[i]); + /* the factory returns nothing for a connection type this build cannot create, for + * instance a gs_usb device in a settings file carried over from Windows */ + if (!conn_p) + { + qDebug() << "Skipping saved connection of unsupported type" << devTypes[i] << portNames[i]; + continue; + } /* add connection to model */ connModel->add(conn_p); } diff --git a/ui/newconnectiondialog.ui b/ui/newconnectiondialog.ui index d59ac6e..d036a62 100644 --- a/ui/newconnectiondialog.ui +++ b/ui/newconnectiondialog.ui @@ -88,7 +88,7 @@ - gs_usb (candleLight, CANable, CANnectivity) + gs_usb (over WinUSB)