From bb35b2f64dfa18c491aed8b8103941325df3228b Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sun, 9 Jan 2022 06:13:13 -0800 Subject: QByteArray: fix append() with a negative length The documentation says that if it's negative, we find the null termination. This bug was introduced with the clean up to use QByteArrayView in commit 8897aa071a668563a53a4c2e6909572f1762b1e7. Fixes: QTBUG-99640 Pick-to: 6.3 6.2 Change-Id: Ib42b3adc93bf4d43bd55fffd16c89fa4a960f3a9 Reviewed-by: Friedemann Kleint Reviewed-by: Marc Mutz --- tests/auto/corelib/text/qbytearray/tst_qbytearray.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'tests/auto/corelib') diff --git a/tests/auto/corelib/text/qbytearray/tst_qbytearray.cpp b/tests/auto/corelib/text/qbytearray/tst_qbytearray.cpp index cecd0f1584..ae65b8d27e 100644 --- a/tests/auto/corelib/text/qbytearray/tst_qbytearray.cpp +++ b/tests/auto/corelib/text/qbytearray/tst_qbytearray.cpp @@ -957,6 +957,7 @@ void tst_QByteArray::append() QCOMPARE(QByteArray().append(2, 'a'), QByteArray("aa")); QCOMPARE(QByteArray().append(QByteArray("data")), QByteArray("data")); QCOMPARE(QByteArray().append(data), QByteArray("data")); + QCOMPARE(QByteArray().append(data, -1), QByteArray("data")); QCOMPARE(QByteArray().append(data, 2), QByteArray("da")); QCOMPARE(QByteArray().append(QByteArrayView(data)), QByteArray("data")); -- cgit v1.2.3