From 6f1d3dd6e69e742daab3d0c7eaaf8f58ac461c81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marvin=20Ha=CC=88user?= <mhaeuser@posteo.de> Date: Sat, 25 Nov 2023 13:08:13 +0100 Subject: [PATCH] [WIP] simulation: fix NULL dereference oLastTrans may be NULL when saving the benchmark to file. The current logic does not handle this correctly, dereferencing it for a print. Print a dummy value when the variable is NULL to resolve the issue. --- simulators/c++2/src_simulator/sim/Simulator.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/simulators/c++2/src_simulator/sim/Simulator.cpp b/simulators/c++2/src_simulator/sim/Simulator.cpp index 103f43e2de..697c35c44d 100644 --- a/simulators/c++2/src_simulator/sim/Simulator.cpp +++ b/simulators/c++2/src_simulator/sim/Simulator.cpp @@ -2542,7 +2542,13 @@ void Simulator::decodeCommand(std::string iCmd, std::ostream &iXmlOutStream) aInpStream >> aParam1; std::cout << "printhtis" << std::endl; - std::cout << TAG_MSGo << oLastTrans->toString() << aStrParam << TAG_MSGc << std::endl; + std::string oLastTransString; + if (oLastTrans == NULL) { + oLastTransString = "<null>"; + } else { + oLastTransString = oLastTrans->toString(); + } + std::cout << TAG_MSGo << oLastTransString << aStrParam << TAG_MSGc << std::endl; switch (aParam1) { case 0: -- GitLab