Fix build with GCC12: avoid QCborStreamReader::preparse()
GCC 12 doesn't like that we're calling preparse() on the empty QByteArray() (whose .data() == &QByteArray::_empty), despite the condition being impossible. Reported at https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105348 In function ‘void* qt_cbor_decoder_read(void*, void*, size_t, size_t)’, inlined from ‘void* read_bytes_unchecked(const CborValue*, void*, size_t, size_t)’ at cborinternal_p.h:234:51, inlined from ‘uint32_t read_uint32(const CborValue*, size_t)’ at cborinternal_p.h:271:25, inlined from ‘uint64_t _cbor_value_decode_int64_internal(const CborValue*)’ at cborparser.c:333:23, inlined from ‘uint64_t _cbor_value_extract_int64_helper(const CborValue*)’ at cbor.h:372:50, inlined from ‘void QCborStreamReader::preparse()’ at qcborstreamreader.cpp:769:59, inlined from ‘QCborStreamReader::QCborStreamReader(const QByteArray&)’ at qcborstreamreader.cpp:825:13, inlined from ‘QCborStreamReader::QCborStreamReader()’ at qcborstreamreader.cpp:790:37, inlined from ‘QtPrivate::QMetaTypeForType<QCborStreamReader>::getDefaultCtr()::<lambda(const QtPrivate::QMetaTypeInterface*, void*)>’ at qmetatype.h:2302:65, inlined from ‘static constexpr void QtPrivate::QMetaTypeForType<QCborStreamReader>::getDefaultCtr()::<lambda(const QtPrivate::QMetaTypeInterface*, void*)>::_FUN(const QtPrivate::QMetaTypeInterface*, void*)’ at qmetatype.h:2302:20: qcborstreamreader.cpp:706:18: error: array subscript ‘unsigned int[0]’ is partly outside array bounds of ‘const char [1]’ [-Werror=array-bounds] qbytearray.h:92:23: note: object ‘QByteArray::_empty’ of size 1 Pick-to: 6.2 6.3 Change-Id: If05aeeb7176e4f13af9afffd16e8485d34e36100 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
This commit is contained in:
parent
54eae2d610
commit
d7d6f46324
@ -565,7 +565,7 @@ public:
|
||||
CborValue currentElement;
|
||||
QCborError lastError = {};
|
||||
|
||||
QByteArray::size_type bufferStart;
|
||||
QByteArray::size_type bufferStart = 0;
|
||||
bool corrupt = false;
|
||||
|
||||
QCborStreamReaderPrivate(const QByteArray &data)
|
||||
@ -787,7 +787,7 @@ inline void QCborStreamReader::preparse()
|
||||
\sa addData(), isValid()
|
||||
*/
|
||||
QCborStreamReader::QCborStreamReader()
|
||||
: QCborStreamReader(QByteArray())
|
||||
: d(new QCborStreamReaderPrivate({})), type_(Invalid)
|
||||
{
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user