From a3926b282e4f3eae0160ea7e3f2ca4d5a7333a03 Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Mon, 23 Nov 2020 23:03:48 +0100 Subject: [PATCH] Fix a crash when opening pro file (Qt6 build) When move c'tor of ProFunctionDef was introduced it became possible, that m_pro may be NULL. In this case we need to destruct this invalid state of ProFunctionDef in a special way: we ensure, that m_pro is not null before calling deref(). Amends: bf5cc934ea8fba4f3516b9f00f44db70becd5bbd Cherry-picks: 907923b7cafad8cff6f0f5c8764e9181ac1531bd from qtbase Task-number: QTCREATORBUG-24840 Change-Id: I5b2643f2241407101dbf95a8d6ea9974cf8ae6ea Reviewed-by: Eike Ziller --- src/shared/proparser/proitems.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/shared/proparser/proitems.h b/src/shared/proparser/proitems.h index dd89c25448a..3e0686fe136 100644 --- a/src/shared/proparser/proitems.h +++ b/src/shared/proparser/proitems.h @@ -421,11 +421,12 @@ public: ProFunctionDef(const ProFunctionDef &o) : m_pro(o.m_pro), m_offset(o.m_offset) { m_pro->ref(); } ProFunctionDef(ProFunctionDef &&other) Q_DECL_NOTHROW : m_pro(other.m_pro), m_offset(other.m_offset) { other.m_pro = nullptr; } - ~ProFunctionDef() { m_pro->deref(); } + ~ProFunctionDef() { if (m_pro) m_pro->deref(); } ProFunctionDef &operator=(const ProFunctionDef &o) { if (this != &o) { - m_pro->deref(); + if (m_pro) + m_pro->deref(); m_pro = o.m_pro; m_pro->ref(); m_offset = o.m_offset;