From 26cfa86969bf7ebde80e16d530800d1c30fb343b Mon Sep 17 00:00:00 2001 From: Christian Stenger Date: Tue, 28 May 2024 09:30:10 +0200 Subject: [PATCH] Cppcheck: Quote file paths This patch fixes the most common issues with path quoting. Fixes: QTCREATORBUG-28586 Change-Id: Ia5f400d062a2459f49288fcd4bc316ced2b269e6 Reviewed-by: Marcus Tillmanns --- src/plugins/cppcheck/cppcheckrunner.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/plugins/cppcheck/cppcheckrunner.cpp b/src/plugins/cppcheck/cppcheckrunner.cpp index 4f9b23646c5..d3f034e80b1 100644 --- a/src/plugins/cppcheck/cppcheckrunner.cpp +++ b/src/plugins/cppcheck/cppcheckrunner.cpp @@ -113,16 +113,17 @@ void CppcheckRunner::checkQueued() if (m_queue.isEmpty() || !m_binary.isExecutableFile()) return; + CommandLine commandLine{m_binary, m_arguments, CommandLine::Raw}; FilePaths files = m_queue.begin().value(); - QString arguments = m_arguments + ' ' + m_queue.begin().key(); + commandLine.addArg(m_queue.begin().key()); m_currentFiles.clear(); - int argumentsLength = arguments.length(); + int argumentsLength = commandLine.arguments().length(); while (!files.isEmpty()) { - argumentsLength += files.first().toString().size() + 1; // +1 for separator + argumentsLength += files.first().toString().size() + 3; // +1 for separator +2 for quotes if (argumentsLength >= m_maxArgumentsLength) break; m_currentFiles.push_back(files.first()); - arguments += ' ' + files.first().toString(); + commandLine.addArg(files.first().toString()); files.pop_front(); } @@ -131,7 +132,7 @@ void CppcheckRunner::checkQueued() else m_queue.begin().value() = files; - m_process.setCommand({m_binary, arguments, CommandLine::Raw}); + m_process.setCommand(commandLine); m_process.start(); }