From ca0cd342f5b339b4bc6188faddf58638ce26e4f1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Remko=20Tron=C3=A7on?= <git@el-tramo.be>
Date: Thu, 11 Nov 2010 21:55:05 +0100
Subject: Handle null OpenSSL X509 cert pointers better.


diff --git a/Swiften/TLS/OpenSSL/OpenSSLCertificate.cpp b/Swiften/TLS/OpenSSL/OpenSSLCertificate.cpp
index 77c0aee..8c6cb25 100644
--- a/Swiften/TLS/OpenSSL/OpenSSLCertificate.cpp
+++ b/Swiften/TLS/OpenSSL/OpenSSLCertificate.cpp
@@ -27,6 +27,10 @@ OpenSSLCertificate::OpenSSLCertificate(const ByteArray& der) {
 }
 
 ByteArray OpenSSLCertificate::toDER() const {
+	if (!cert) {
+		return ByteArray();
+	}
+
 	ByteArray result;
 	result.resize(i2d_X509(cert.get(), NULL));
 	unsigned char* p = reinterpret_cast<unsigned char*>(result.getData());
@@ -35,6 +39,10 @@ ByteArray OpenSSLCertificate::toDER() const {
 }
 
 void OpenSSLCertificate::parse() {
+	if (!cert) {
+		return;
+	}
+
 	// Subject name
 	X509_NAME* subjectName = X509_get_subject_name(cert.get());
 	if (subjectName) {
-- 
cgit v0.10.2-6-g49f6