From 6ee5a7f7d7e0809bae73adb198c746e0d8b9e7cf Mon Sep 17 00:00:00 2001 From: Collin Kidder Date: Tue, 24 Jul 2018 21:35:42 -0400 Subject: [PATCH] Add checks to ensure that references to nonexistant nodes are handled --- dbc/dbchandler.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/dbc/dbchandler.cpp b/dbc/dbchandler.cpp index 7e76550..6f1c8e3 100644 --- a/dbc/dbchandler.cpp +++ b/dbc/dbchandler.cpp @@ -347,6 +347,7 @@ DBC_MESSAGE* DBCFile::parseMessageLine(QString line) msg.name = match.captured(2); msg.len = match.captured(3).toInt(); msg.sender = findNodeByName(match.captured(4)); + if (!msg.sender) msg.sender = findNodeByIdx(0); messageHandler->addMessage(msg); msgPtr = messageHandler->findMsgByID(msg.ID); } @@ -450,9 +451,12 @@ DBC_SIGNAL* DBCFile::parseSignalLine(QString line, DBC_MESSAGE *msg) if (match.captured(11 + offset).contains(',')) { QString tmp = match.captured(11 + offset).split(',')[0]; - sig.receiver = findNodeByName(tmp); + sig.receiver = findNodeByName(tmp); } else sig.receiver = findNodeByName(match.captured(11 + offset)); + + if (!sig.receiver) sig.receiver = findNodeByIdx(0); //apply default if there was no match + sig.parentMessage = msg; msg->sigHandler->addSignal(sig); if (isMultiplexor) msg->multiplexorSignal = msg->sigHandler->findSignalByName(sig.name);