From c430649768260d341dc261b086f2c6913ac8496a Mon Sep 17 00:00:00 2001
From: con <qtc-committer@nokia.com>
Date: Tue, 28 Jul 2009 17:40:15 +0200
Subject: [PATCH] Sending a string should send a trainling zero as well.

---
 tests/manual/trk/adapter.cpp  | 2 --
 tests/manual/trk/launcher.cpp | 5 +----
 tests/manual/trk/trkutils.cpp | 3 ++-
 3 files changed, 3 insertions(+), 7 deletions(-)

diff --git a/tests/manual/trk/adapter.cpp b/tests/manual/trk/adapter.cpp
index a03d6725e35..7880e9cfef0 100644
--- a/tests/manual/trk/adapter.cpp
+++ b/tests/manual/trk/adapter.cpp
@@ -1442,8 +1442,6 @@ void Adapter::startInferiorIfNeeded()
     appendByte(&ba, 0); // ?
 
     QByteArray file("C:\\sys\\bin\\filebrowseapp.exe");
-    file.append('\0');
-    file.append('\0');
     appendString(&ba, file, TargetByteOrder);
     sendTrkMessage(0x40, CB(handleCreateProcess), ba); // Create Item
 }
diff --git a/tests/manual/trk/launcher.cpp b/tests/manual/trk/launcher.cpp
index dc3cbded0db..a83985a0849 100644
--- a/tests/manual/trk/launcher.cpp
+++ b/tests/manual/trk/launcher.cpp
@@ -629,10 +629,7 @@ void Adapter::startInferiorIfNeeded()
     appendByte(&ba, 0); // ?
     appendByte(&ba, 0); // ?
     appendByte(&ba, 0); // ?
-    QByteArray file = m_fileName.toLocal8Bit();
-    file.append('\0');
-    file.append('\0');
-    appendString(&ba, file, TargetByteOrder);
+    appendString(&ba, m_fileName.toLocal8Bit(), TargetByteOrder);
     sendTrkMessage(TrkCreateItem, CB(handleCreateProcess), ba); // Create Item
 }
 
diff --git a/tests/manual/trk/trkutils.cpp b/tests/manual/trk/trkutils.cpp
index 43395ea99af..d29acb535e7 100644
--- a/tests/manual/trk/trkutils.cpp
+++ b/tests/manual/trk/trkutils.cpp
@@ -264,9 +264,10 @@ void appendInt(QByteArray *ba, uint i, Endianness endian)
 void appendString(QByteArray *ba, const QByteArray &str, Endianness endian)
 {
     const int n = str.size();
-    appendShort(ba, n, endian);
+    appendShort(ba, n+1, endian); // count the terminating \0
     for (int i = 0; i != n; ++i)
         ba->append(str.at(i));
+    ba->append('\0');
 }
 
 QByteArray errorMessage(byte code)
-- 
GitLab