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 Change-Id: I24de914faa25dc7cb1da5eae09a125506caac389 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit 52b5e9b76663fa7b43da1466fb2678d6b18d86b2) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
3d1a007d95
commit
43fe602ea3
@ -855,8 +855,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;
|
||||
@ -2157,12 +2161,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…
x
Reference in New Issue
Block a user