From fe8afc4649ab348ef297dddd677b5eae4543a1da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sl=C3=A1vek=20Banko?= Date: Fri, 10 Jan 2020 03:02:41 +0100 Subject: Add safety check for from.d->c in Cert::operator=. Taken from a copy of TQCA in tdenetwork/kopete/groupwise. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Slávek Banko --- src/tqca.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/tqca.cpp b/src/tqca.cpp index 3ff9a58..8eb7bb5 100644 --- a/src/tqca.cpp +++ b/src/tqca.cpp @@ -696,6 +696,7 @@ public: Cert::Cert() { d = new Private; + // crash because this is returning 0 d->c = (TQCA_CertContext *)getContext(CAP_X509); } @@ -708,7 +709,10 @@ Cert::Cert(const Cert &from) Cert & Cert::operator=(const Cert &from) { delete d->c; - d->c = from.d->c->clone(); + if ( from.d->c ) + d->c = from.d->c->clone(); + else + d->c = 0; return *this; } @@ -837,6 +841,7 @@ public: to_net.resize(0); host = ""; hostMismatch = false; + // this causes the crash, because the Cert ctor is setting a null context cert = Cert(); bytesEncoded = 0; tryMore = false; -- cgit v1.2.1