diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2020-11-11 12:50:54 -0800 |
---|---|---|
committer | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2020-12-06 07:50:57 +0000 |
commit | 9a55f40937d037d06e00b09465d8dad0554692fc (patch) | |
tree | 29da13d4e2d82bca83e68b4a52713ae9ed71aee5 /src/corelib/serialization/qcborvalue_p.h | |
parent | c16ad16bd0a1d51d559eed8a4f2f10ac1518f6aa (diff) |
QCborStreamReader: avoid allocating result if data is insufficient
By calling the internal readStringChunk() function with a QByteArray
pointer, QCborStreamReader::readByteArray() can now avoid allocating the
resulting buffer until the internals have confirmed that there is
sufficient data in the incoming buffer. As a result, we first detect the
EOF condition before we conclude the payload would have been too big for
QByteArray (validation()) test. Meanwhile, the hugeDeviceValidation()
test ends up with a few conditions where it would have copied 1 GB of
data, so limit that too.
We make a choice of reporting OOM vs DataTooLarge only if QByteArray
fails to allocate in the first place (QByteArray::resize() ->
Q_CHECK_PTR -> qBadAlloc, QtCore is always built with exceptions on).
The QCborValue unit test needed a temporary work around until we apply
the same allocation fix (see next commit).
Pick-to: 5.15 6.0
Fixes: QTBUG-88253
Change-Id: I7b9b97ae9b32412abdc6fffd164523eeae49cdfe
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'src/corelib/serialization/qcborvalue_p.h')
0 files changed, 0 insertions, 0 deletions