From 6064bdc1a568ab41019244944dc1833f964b9d82 Mon Sep 17 00:00:00 2001 From: Steve Brokenshire Date: Mon, 16 May 2016 22:17:07 +0100 Subject: [PATCH] Check for NULL pointers for CertificateData in the GetCertificateContextPointer and GetCertificateContext functions in the CardDAV object. --- source/carddav/carddav.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/source/carddav/carddav.cpp b/source/carddav/carddav.cpp index 7e73c5f..52ae03a 100644 --- a/source/carddav/carddav.cpp +++ b/source/carddav/carddav.cpp @@ -529,6 +529,14 @@ void CardDAV::SetConnectionObject(CURL *ConnectionObjectIn){ PCCERT_CONTEXT CardDAV::GetCertificateContextPointer(){ + // Check that the PCCERT_CONTEXT has an address + // other than NULL. Return nullptr if this is the + // case. + + if (CertificateData == NULL){ + return NULL; + } + // Get the certificate data. return CertificateData; @@ -537,6 +545,15 @@ PCCERT_CONTEXT CardDAV::GetCertificateContextPointer(){ CERT_CONTEXT CardDAV::GetCertificateContext(){ + // Check that the PCCERT_CONTEXT has an address + // other than NULL. Return nullptr if this is the + // case. + + if (CertificateData == NULL){ + CERT_CONTEXT EmptyCertificateData = { 0 }; + return EmptyCertificateData; + } + // Get the certificate data. return *CertificateData; -- 2.39.5