summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2016-11-01 22:32:05 -0700
committerThiago Macieira <thiago.macieira@intel.com>2016-11-24 01:20:49 +0000
commited84b8b4ff88c5affaa89edb72e6aaf481f3ccc1 (patch)
tree845ada9b1f381aa8d9b6d5f63234360acecc718b
parentd542341492a0c18058b3f03008ea8916d84ccef3 (diff)
downloadqtwebkit-ed84b8b4ff88c5affaa89edb72e6aaf481f3ccc1.tar.gz
Fix QDataStreamCoder encoding and decoding of binary data
This code was all wrong. The dereferencing of the pointer was missing, so QDataStreamCoder::encodeBytes was encoding pointers (cast to something, though unclear what), while the decoder was decoding them one byte at a time This clearly has never worked. So just use writeRawData and readRawData. Change-Id: Ic46ff326a6ba46bc877cfffd1483240963ec5ee0 Reviewed-by: Konstantin Tokarev <annulen@yandex.ru> Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
-rw-r--r--Source/WebCore/history/qt/HistoryItemQt.cpp11
1 files changed, 3 insertions, 8 deletions
diff --git a/Source/WebCore/history/qt/HistoryItemQt.cpp b/Source/WebCore/history/qt/HistoryItemQt.cpp
index 5a54516f3..89777eb72 100644
--- a/Source/WebCore/history/qt/HistoryItemQt.cpp
+++ b/Source/WebCore/history/qt/HistoryItemQt.cpp
@@ -81,8 +81,7 @@ QDataStreamCoder::QDataStreamCoder(QDataStream& stream)
void QDataStreamCoder::encodeBytes(const uint8_t* bytes, size_t size)
{
m_stream << qint64(size);
- for (; size > 0; --size)
- m_stream << bytes++;
+ m_stream.writeRawData(reinterpret_cast<const char *>(bytes++), size);
}
void QDataStreamCoder::encodeBool(bool value)
@@ -129,13 +128,9 @@ bool QDataStreamCoder::decodeBytes(Vector<uint8_t>& out)
{
out.clear();
qint64 count;
- uint8_t byte;
m_stream >> count;
- out.reserveCapacity(count);
- for (qint64 i = 0; i < count; ++i) {
- m_stream >> byte;
- out.append(byte);
- }
+ out.resize(count);
+ m_stream.readRawData(reinterpret_cast<char *>(out.data()), count);
return m_stream.status() == QDataStream::Ok;
}