From af03f49bf736e7ef636e0d7d4908ca59c257ac57 Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Thu, 16 Feb 2023 14:22:48 +0100 Subject: [PATCH] LlvmFileSystemAdapter: Don't use uninitialized memory Create std::string explicitly using pointer to data and data size. SmallVectorImpl doesn't include terminating \0, so passing data size is needed. Fixes: QTCREATORBUG-28812 Change-Id: I63bd290e990ec8e4cd4fb609764a79e6feff92bc Reviewed-by: hjk Reviewed-by: Qt CI Bot Reviewed-by: --- src/plugins/clangformat/llvmfilesystem.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/plugins/clangformat/llvmfilesystem.h b/src/plugins/clangformat/llvmfilesystem.h index 3589515ad35..675791f349e 100644 --- a/src/plugins/clangformat/llvmfilesystem.h +++ b/src/plugins/clangformat/llvmfilesystem.h @@ -151,7 +151,8 @@ public: Path.assign(asString.begin(), asString.end()); return {}; } - const FilePath filePath = FilePath::fromString(QString::fromStdString(Path.data())); + const FilePath filePath = FilePath::fromString(QString::fromStdString( + std::string(Path.data(), Path.size()))); if (filePath.isRelativePath()) { const std::string asString = m_workingDirectory.resolvePath(filePath).toFSPathString().toStdString();