Assert that either both or neither pointer are nullptr
If called by QMetaType::canConvert with two nullptr values, the QMETATYPE_CONVERTER_ASSIGN macro will expand to code dereferencing both 'to' and 'from' pointers. Assert that others callers provide two valid pointers. Fixes static analyzer warning 02dc34cc2ad1d4c3c6e55b44e08983f2 Pick-to: 6.1 Change-Id: I24de914faa25dc7cb1da5eae09a125506caac389 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>bb10
parent
f6c9dec610
commit
52b5e9b766
|
|
@ -857,8 +857,12 @@ static const struct : QMetaTypeModuleHelper
|
|||
{
|
||||
Q_ASSERT(fromTypeId != toTypeId);
|
||||
|
||||
// canConvert calls with two nullptr
|
||||
bool onlyCheck = (from == nullptr && to == nullptr);
|
||||
|
||||
// other callers must provide two valid pointers
|
||||
Q_ASSERT(onlyCheck || (bool(from) && bool(to)));
|
||||
|
||||
using Char = char;
|
||||
using SChar = signed char;
|
||||
using UChar = unsigned char;
|
||||
|
|
@ -2159,12 +2163,18 @@ static bool convertQObject(QMetaType fromType, const void *from, QMetaType toTyp
|
|||
|
||||
Converts the object at \a from from \a fromTypeId to the preallocated space at \a to
|
||||
typed \a toTypeId. Returns \c true, if the conversion succeeded, otherwise false.
|
||||
|
||||
Both \a from and \a to have to be valid pointers.
|
||||
|
||||
\since 5.2
|
||||
*/
|
||||
|
||||
/*!
|
||||
Converts the object at \a from from \a fromType to the preallocated space at \a to
|
||||
typed \a toType. Returns \c true, if the conversion succeeded, otherwise false.
|
||||
|
||||
Both \a from and \a to have to be valid pointers.
|
||||
|
||||
\since 5.2
|
||||
*/
|
||||
bool QMetaType::convert(QMetaType fromType, const void *from, QMetaType toType, void *to)
|
||||
|
|
|
|||
Loading…
Reference in New Issue