diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2022-11-28 09:29:02 +0100 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2022-11-30 12:28:19 +0100 |
commit | 410449ea21b7f8af02303891ae59e35579283f40 (patch) | |
tree | 4a31d33311ad4ce0d6a49ce6f1018ccb48988844 /src | |
parent | cf471f9a91d6508008fcef6d181483de5936fb9c (diff) |
QTaggedPointer: Assert on the same tag value as we use in setTag()
If we assert on a different cast we may just get a different integer
value, if Tag is a sufficiently nefarious type.
Coverity-Id: 403056
Change-Id: I6e8e3883bce124b3350ad8276d88ac7ed030d982
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/tools/qtaggedpointer.h | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/corelib/tools/qtaggedpointer.h b/src/corelib/tools/qtaggedpointer.h index a08912c4a5..d0c180ac5f 100644 --- a/src/corelib/tools/qtaggedpointer.h +++ b/src/corelib/tools/qtaggedpointer.h @@ -104,8 +104,10 @@ public: void setTag(Tag tag) { - Q_ASSERT_X((static_cast<typename QtPrivate::TagInfo<T>::TagType>(tag) & pointerMask()) == 0, - "QTaggedPointer<T, Tag>::setTag", "Tag is larger than allowed by number of available tag bits"); + Q_ASSERT_X( + (static_cast<quintptr>(tag) & pointerMask()) == 0, + "QTaggedPointer<T, Tag>::setTag", + "Tag is larger than allowed by number of available tag bits"); d = (d & pointerMask()) | static_cast<quintptr>(tag); } |