qmlfrontend/game_config.cpp
changeset 14296 61bc44de2b4c
parent 14295 0ae9885e1535
--- a/qmlfrontend/game_config.cpp	Thu Nov 22 13:52:00 2018 +0100
+++ b/qmlfrontend/game_config.cpp	Thu Nov 22 14:07:55 2018 +0100
@@ -58,18 +58,18 @@
 void GameConfig::cfgAppend(const QByteArray& cmd) {
   Q_ASSERT(cmd.size() <= 49215);
 
+  QByteArray sizeBytes;
   if (cmd.size() < 64) {
     quint8 len = static_cast<quint8>(cmd.size());
-    m_cfg.append(
-        QByteArray::fromRawData(reinterpret_cast<const char*>(&len), 1));
+    sizeBytes = QByteArray::fromRawData(reinterpret_cast<const char*>(&len), 1);
   } else {
     quint16 size = static_cast<quint16>(cmd.size()) - 64;
     size = (size / 256 + 64) * 256 + size & 0xff;
     quint16 size_be = qToBigEndian(size);
 
-    m_cfg.append(
-        QByteArray::fromRawData(reinterpret_cast<const char*>(&size_be), 2));
+    sizeBytes =
+        QByteArray::fromRawData(reinterpret_cast<const char*>(&size_be), 2);
   }
 
-  m_cfg.append(cmd);
+  m_cfg.append(sizeBytes + cmd);
 }