summaryrefslogtreecommitdiff
path: root/src/spawn.cpp
diff options
context:
space:
mode:
authorTannin <devnull@localhost>2015-02-25 18:38:01 +0100
committerTannin <devnull@localhost>2015-02-25 18:38:01 +0100
commit6479f972dccaabb3afadb570583a4269e8a785e4 (patch)
treeb36ec1afc65e123b893215a2529bb20c25041adb /src/spawn.cpp
parente01ab940b0d76bfec8d7037ee56938780a74dc5b (diff)
tons of code cleanup and minor fixes to harden the code (mostly suggestions from static code analysis)
Diffstat (limited to 'src/spawn.cpp')
-rw-r--r--src/spawn.cpp6
1 files changed, 3 insertions, 3 deletions
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<TCHAR> 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());