From 6479f972dccaabb3afadb570583a4269e8a785e4 Mon Sep 17 00:00:00 2001 From: Tannin Date: Wed, 25 Feb 2015 18:38:01 +0100 Subject: tons of code cleanup and minor fixes to harden the code (mostly suggestions from static code analysis) --- src/spawn.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/spawn.cpp') diff --git a/src/spawn.cpp b/src/spawn.cpp index c031b25e..b1127df3 100644 --- a/src/spawn.cpp +++ b/src/spawn.cpp @@ -61,7 +61,7 @@ static bool spawn(LPCWSTR binary, LPCWSTR arguments, LPCWSTR currentDirectory, b _snwprintf(commandLine, length, L"\"%ls\" %ls", binary, arguments); } else { commandLine = new wchar_t[length]; - _snwprintf(commandLine, length, L"\"%ls\"", binary); + _snwprintf_s(commandLine, length, _TRUNCATE, L"\"%ls\"", binary); } QString moPath = QCoreApplication::applicationDirPath(); @@ -75,8 +75,8 @@ static bool spawn(LPCWSTR binary, LPCWSTR arguments, LPCWSTR currentDirectory, b { boost::scoped_array newPath(new TCHAR[offset + moPath.length() + 2]); - _tcsncpy(newPath.get(), oldPath.get(), offset - 1); - newPath.get()[offset - 1] = L'\0'; + _tcsncpy(newPath.get(), oldPath.get(), offset); + newPath.get()[offset] = '\0'; _tcsncat(newPath.get(), TEXT(";"), 1); _tcsncat(newPath.get(), ToWString(QDir::toNativeSeparators(moPath)).c_str(), moPath.length()); -- cgit v1.3.1