]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
vtls: exit addsessionid if no cache is inited
authorDaniel Stenberg <daniel@haxx.se>
Tue, 1 Jun 2021 09:17:27 +0000 (11:17 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Tue, 1 Jun 2021 11:40:30 +0000 (13:40 +0200)
Follow-up to b249592d29ae0

Avoids NULL pointer derefs.

Closes #7165

lib/vtls/vtls.c

index 1e6272b9f2d817ca92bc92bec6fb0d6d3c4d229d..e49f8eafb2bdf3916185c895cf6505de669c9371 100644 (file)
@@ -499,8 +499,8 @@ CURLcode Curl_ssl_addsessionid(struct Curl_easy *data,
                                int sockindex)
 {
   size_t i;
-  struct Curl_ssl_session *store = &data->state.session[0];
-  long oldest_age = data->state.session[0].age; /* zero if unused */
+  struct Curl_ssl_session *store;
+  long oldest_age;
   char *clone_host;
   char *clone_conn_to_host;
   int conn_to_port;
@@ -516,6 +516,11 @@ CURLcode Curl_ssl_addsessionid(struct Curl_easy *data,
   const char *hostname = conn->host.name;
 #endif
   (void)sockindex;
+  if(!data->state.session)
+    return CURLE_OK;
+
+  store = &data->state.session[0];
+  oldest_age = data->state.session[0].age; /* zero if unused */
   DEBUGASSERT(SSL_SET_OPTION(primary.sessionid));
 
   clone_host = strdup(hostname);