]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
socks: fix query when filter context is null
authorStefan Eissing <stefan@eissing.org>
Thu, 10 Jul 2025 10:29:25 +0000 (12:29 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Thu, 10 Jul 2025 15:28:49 +0000 (17:28 +0200)
socks connection filter context may be NULL at the time
of a query, accomodate for that.

Closes #17885

lib/socks.c

index 10a307dc5ceb5029361c239ce7cce34e92badbe5..c7af0f4cb3d6d0590de4b92aaf92192e325238bc 100644 (file)
@@ -1193,13 +1193,15 @@ static CURLcode socks_cf_query(struct Curl_cfilter *cf,
 {
   struct socks_state *sx = cf->ctx;
 
-  switch(query) {
-  case CF_QUERY_HOST_PORT:
-    *pres1 = sx->remote_port;
-    *((const char **)pres2) = sx->hostname;
-    return CURLE_OK;
-  default:
-    break;
+  if(sx) {
+    switch(query) {
+    case CF_QUERY_HOST_PORT:
+      *pres1 = sx->remote_port;
+      *((const char **)pres2) = sx->hostname;
+      return CURLE_OK;
+    default:
+      break;
+    }
   }
   return cf->next ?
     cf->next->cft->query(cf->next, data, query, pres1, pres2) :