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 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XZnuZJ7zc3e8hk6C8bGDZN
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@
|
||||
<item row="8" column="0">
|
||||
<widget class="QRadioButton" name="rbGSUSB">
|
||||
<property name="text">
|
||||
<string>gs_usb (candleLight, CANable, CANnectivity)</string>
|
||||
<string>gs_usb (over WinUSB)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
Reference in New Issue
Block a user