[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kio] src/ioslaves/help: help: fix garbage sent when serving static files
From:       Pino Toscano <pino () kde ! org>
Date:       2016-01-31 11:41:29
Message-ID: E1aPqNl-0005qO-Lj () scm ! kde ! org
[Download RAW message or body]

Git commit 3642b5284e65d94db22a86d52e710dd60e15b230 by Pino Toscano.
Committed on 31/01/2016 at 11:41.
Pushed by pino into branch 'master'.

help: fix garbage sent when serving static files

Switch from a QByteArray to a simplier stack-based char array, using
the actual number of bytes read when sending the data using data()
(reusing the memory from the array).

This removes the garbage sent when serving static files, i.e. those
stored in directories and not as part of a .cache.bz2 file.

REVIEW: 126936

M  +3    -4    src/ioslaves/help/kio_help.cpp

http://commits.kde.org/kio/3642b5284e65d94db22a86d52e710dd60e15b230

diff --git a/src/ioslaves/help/kio_help.cpp b/src/ioslaves/help/kio_help.cpp
index 7b97599..0a6bab4 100644
--- a/src/ioslaves/help/kio_help.cpp
+++ b/src/ioslaves/help/kio_help.cpp
@@ -383,11 +383,10 @@ void HelpProtocol::get_file(const QString &path)
     int processed_size = 0;
     totalSize(f.size());
 
-    QByteArray array;
-    array.resize(MAX_IPC_SIZE);
+    char array[MAX_IPC_SIZE];
 
     Q_FOREVER {
-    const qint64 n = f.read(array.data(), array.size());
+        const qint64 n = f.read(array, sizeof(array));
         if (n == -1)
         {
             error(KIO::ERR_CANNOT_READ, path);
@@ -398,7 +397,7 @@ void HelpProtocol::get_file(const QString &path)
             break;    // Finished
         }
 
-        data(array);
+        data(QByteArray::fromRawData(array, n));
 
         processed_size += n;
         processedSize(processed_size);
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic