Skip to content

QShader: fix memory leak in detach()

qAtomicDetach() does d = new T(*d); which calls the copy constructor. Since there was no copy constructor declared for QShaderPrivate, the compiler generated one which copied the refcount over, instead of setting it to 1 in the detached instance. As a result, the destructor didn't delete the QShaderPrivate.

Nothing was calling this constructor that takes a pointer, so clearly this was a typo for a copy constructor.

Detected in an ASAN build, the qsb tool exited in error.

Pick-to: 6.3 6.2 5.15 Change-Id: Idbe659b52d2600ac7c11b09142a6aa5b25310df9 Reviewed-by: Laszlo Agocs laszlo.agocs@qt.io (cherry picked from commit fd4672d0)

  • asturmlechner 2022-06-09: Fix conflict with dev branch commit 04cdde30

Merge request reports