summaryrefslogtreecommitdiff
path: root/src/gui/text/qtextformat.cpp
diff options
context:
space:
mode:
authorGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>2020-07-12 14:29:24 +0200
committerGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>2020-07-12 21:48:18 +0200
commit23444d4b26a13677a2029a2b5a53bfae76647b71 (patch)
treec0960b1bba12da08dd2924d22b261c5e4b674576 /src/gui/text/qtextformat.cpp
parent20848f6e8316fc440202a3bc193956aee7a00b5a (diff)
downloadqtbase-23444d4b26a13677a2029a2b5a53bfae76647b71.tar.gz
QCryptographicHash: explicitly activate the used union member
A union member lifetime does not start automatically if one takes a pointer to a union member and writes into the member. Only the subscript syntax in an assignment features such automatic lifetime start [class.union§6]. In the other cases, one is allowed to get a pointer to the storage ([basic.life§6]) but has to start lifetime explicitly via placement new. Hence, do so, or we end up in UB land. We're left with the problem of reset() which may be called multiple times. I think we can actually just create a new object in the same storage without destroying the pre-existing object by exploiting [basic.life§5]: reusing the storage causes lifetime end for the old object. Moreover, since the union is over trivial datatypes (C structs), there's no side effects in the destructor of the old object, so there is no need to call it. Drive by fix, apply some DRY for SHA3. Change-Id: Idc351568635e59d45421311f043956ab3aabf389 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Linus Jahn <lnj@kaidan.im>
Diffstat (limited to 'src/gui/text/qtextformat.cpp')
0 files changed, 0 insertions, 0 deletions