From cb1176364146c44eea94b4b9ba7e3428cf8a3de4 Mon Sep 17 00:00:00 2001 From: hjk Date: Wed, 9 Nov 2022 17:05:35 +0100 Subject: [PATCH] Utils: Fix nullptr access when shell script process fails When the QtcProcess failed to start, we immediately delete it. Later it would try to access it to retrieve the command line for the error message, which would crash. Change-Id: Ibac942e9a1a91001d90ce7e73d5463c51af81590 Reviewed-by: hjk Reviewed-by: --- src/libs/utils/deviceshell.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/libs/utils/deviceshell.cpp b/src/libs/utils/deviceshell.cpp index 1712f5390f8..dd0abd107cf 100644 --- a/src/libs/utils/deviceshell.cpp +++ b/src/libs/utils/deviceshell.cpp @@ -182,6 +182,8 @@ bool DeviceShell::start() setupShellProcess(m_shellProcess.get()); + CommandLine cmdLine = m_shellProcess->commandLine(); + m_shellProcess->setProcessMode(ProcessMode::Writer); // Moving the process into its own thread ... @@ -232,7 +234,7 @@ bool DeviceShell::start() &result); if (!result) { - startupFailed(m_shellProcess->commandLine()); + startupFailed(cmdLine); } return result;