Add safety check for from.d->c in Cert::operator=.

Taken from a copy of TQCA in tdenetwork/kopete/groupwise.

Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
remotes/origin/feat/add_tls_plugin
Slávek Banko 4 years ago
parent 2eade3294c
commit fe8afc4649
No known key found for this signature in database
GPG Key ID: 608F5293A04BE668

@ -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;

Loading…
Cancel
Save