qCompress: return null, not empty, for OOM
While this is a behavior change, we never documented that we'd return an empty instead of a null QByteArray in this situation. Indeed, returning bazip, with its fully-preserved capacity, is an expensive way of signalling an error condition. Conclude that this is not what the original author wanted and return a default-constructed byte array instead, leaving bazip and its excess capacity to be destroyed before the return from the function. Task-number: QTBUG-104972 Task-number: QTBUG-106542 Change-Id: I2ee1fc6fdbb9da28f1987b16915516b51bb348c3 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> (cherry picked from commit 98d9cfabc19984d75951f7ee66037331da63c0b8) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
11064b948b
commit
ebf3bc689c
@ -606,9 +606,8 @@ QByteArray qCompress(const uchar* data, qsizetype nbytes, int compressionLevel)
|
|||||||
qToBigEndian(CompressSizeHint_t(nbytes), bazip.data());
|
qToBigEndian(CompressSizeHint_t(nbytes), bazip.data());
|
||||||
break;
|
break;
|
||||||
case Z_MEM_ERROR:
|
case Z_MEM_ERROR:
|
||||||
qWarning("qCompress: Z_MEM_ERROR: Not enough memory");
|
return tooMuchData(ZLibOp::Compression);
|
||||||
bazip.resize(0);
|
|
||||||
break;
|
|
||||||
case Z_BUF_ERROR:
|
case Z_BUF_ERROR:
|
||||||
len *= 2;
|
len *= 2;
|
||||||
break;
|
break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user