socks: fix query when filter context is null

socks connection filter context may be NULL at the time
of a query, accomodate for that.

Closes #17885
This commit is contained in:
Stefan Eissing 2025-07-10 12:29:25 +02:00 committed by Daniel Stenberg
parent 51369ae78b
commit 74a94e699a
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2

View 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) :