diff options
| author | Marc Mutz <[email protected]> | 2021-12-22 09:16:36 +0100 |
|---|---|---|
| committer | Marc Mutz <[email protected]> | 2021-12-22 13:41:30 +0100 |
| commit | 58058794b1379f153d28d844d5220298f21bcf96 (patch) | |
| tree | 2e729cb9546cd54236ae038aecf617497c1da9aa /src/widgets/kernel/qwidgetwindow.cpp | |
| parent | b6239f70f57961cceec5f0c5f56e3f94b1d5a92a (diff) | |
tst_qmetatype: fix memleaks
We didn't delete the new'ed up QMetaTypeInterfaces, causing asan to
complain.
Fix by storing them in strong references alongside their users in a
statically-allocated container.
We use shared_ptr to hold them, because QMetaTypeInterface doesn't
have a virtual destructor, so deleting objects of the TypeInfo types
(plural!) derived from QMetaTypeInterface though a pointer to the base
class is UB. The shared_ptr constructor, however, is templated, so it
stores the correct call (~TypeInfo()) in its type-erased deleter.
We can't use std::make_shared(), because that doesn't support
aggregate initialization until C++20, so we manually new up the
TypeInfos.
5.15 is not affected.
Pick-to: 6.3 6.2
Change-Id: Ic7ec88c34e02a9e0dd3421848c0c0885f4756702
Reviewed-by: Volker Hilsheimer <[email protected]>
Reviewed-by: Andrei Golubev <[email protected]>
Diffstat (limited to 'src/widgets/kernel/qwidgetwindow.cpp')
0 files changed, 0 insertions, 0 deletions
