Details
-
Task
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
d496f8c79 (dev), e61da05b1 (dev), 427047314 (dev), 50548cd9d (dev), 7e8dbc0fc (dev), 1065fdd04 (dev), cd24a13ae (dev), 0529361a9 (dev), 057b143fd (dev), 92c774594 (dev), ce4460198 (dev), aba9359de (dev), 1c34d3e81 (dev), f3b881a0c (dev), 74a4b2789 (dev)
Description
Quite a few of our tests are using raw new and delete – or even only new without delete.
This is bad, as a failing test might not reach the delete call, and consequently leak memory (or in the case of missing delete, unconditionally leak memory).
While it doesn't really hurt the test itself it it leaks memory, it makes it impossible to rely on ASAN to catch memory leaks in the framework code itself while running the test suite.
There are a few common patterns:
- There's a call to QQmlComponent::create, and the returned object is not free'd – compare https://codereview.qt-project.org/c/qt/qtdeclarative/+/222629
- There's a QCOMPARE/QVERIFY macro between new and delete – compare https://codereview.qt-project.org/c/qt/qtdeclarative/+/381798
Solve this by making sure that owned pointers are always stored in a std::unique_ptr, and replace calls to delete with calls to std::unique_ptr::reset (unless the unique pointer is no longer used afterwards).