From 7bb36ddaa25e17df3ab3b6bf3454f1e7957d444d Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sat, 28 Jun 2014 12:12:03 +0200
Subject: [PATCH] libfetch: fetch_close: make sure conn->ssl is valid before
 shutting down.

---
 lib/fetch/common.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/lib/fetch/common.c b/lib/fetch/common.c
index 5b03348..7764b27 100644
--- lib/fetch/common.c
+++ lib/fetch/common.c
@@ -732,8 +732,10 @@ fetch_close(conn_t *conn)
 	int ret;
 
 #ifdef WITH_SSL
-	SSL_shutdown(conn->ssl);
-	SSL_free(conn->ssl);
+	if (conn->ssl) {
+		SSL_shutdown(conn->ssl);
+		SSL_free(conn->ssl);
+	}
 #endif
 	ret = close(conn->sd);
 	if (conn->cache_url)
-- 
2.0.1

