Skip to content

Commit b8604fe

Browse files
committed
lib/cf-h1-proxy: silence gcc 14 warnings
They came up ealier with gcc 12 (Windows), but apparently gcc 14 is still reporting them, also under Linux. ``` /home/runner/work/curl-for-win/curl-for-win/curl/lib/cf-h1-proxy.c: In function 'cf_h1_proxy_close': /home/runner/work/curl-for-win/curl-for-win/curl/lib/cf-h1-proxy.c:1060:17: warning: null pointer dereference [-Wnull-dereference] 1060 | cf->connected = FALSE; /home/runner/work/curl-for-win/curl-for-win/curl/lib/cf-h1-proxy.c:1061:8: warning: null pointer dereference [-Wnull-dereference] 1061 | if(cf->ctx) { | ~~^~~~~ In function 'tunnel_free', inlined from 'cf_h1_proxy_destroy' at /home/runner/work/curl-for-win/curl-for-win/curl/lib/cf-h1-proxy.c:1053:3: /home/runner/work/curl-for-win/curl-for-win/curl/lib/cf-h1-proxy.c:198:27: warning: null pointer dereference [-Wnull-dereference] 198 | struct h1_tunnel_state *ts = cf->ctx; | ^~ ``` Ref: https://github.com/curl/curl-for-win/actions/runs/8985369476/job/24679219528#step:3:6320 Fixes curl#13237 Close #xxxxx
1 parent 62ae1f1 commit b8604fe

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

lib/cf-h1-proxy.c

+17-13
Original file line numberDiff line numberDiff line change
@@ -195,14 +195,16 @@ static void h1_tunnel_go_state(struct Curl_cfilter *cf,
195195
static void tunnel_free(struct Curl_cfilter *cf,
196196
struct Curl_easy *data)
197197
{
198-
struct h1_tunnel_state *ts = cf->ctx;
199-
if(ts) {
200-
h1_tunnel_go_state(cf, ts, H1_TUNNEL_FAILED, data);
201-
Curl_dyn_free(&ts->rcvbuf);
202-
Curl_dyn_free(&ts->request_data);
203-
Curl_httpchunk_free(data, &ts->ch);
204-
free(ts);
205-
cf->ctx = NULL;
198+
if(cf) {
199+
struct h1_tunnel_state *ts = cf->ctx;
200+
if(ts) {
201+
h1_tunnel_go_state(cf, ts, H1_TUNNEL_FAILED, data);
202+
Curl_dyn_free(&ts->rcvbuf);
203+
Curl_dyn_free(&ts->request_data);
204+
Curl_httpchunk_free(data, &ts->ch);
205+
free(ts);
206+
cf->ctx = NULL;
207+
}
206208
}
207209
}
208210

@@ -1057,12 +1059,14 @@ static void cf_h1_proxy_close(struct Curl_cfilter *cf,
10571059
struct Curl_easy *data)
10581060
{
10591061
CURL_TRC_CF(data, cf, "close");
1060-
cf->connected = FALSE;
1061-
if(cf->ctx) {
1062-
h1_tunnel_go_state(cf, cf->ctx, H1_TUNNEL_INIT, data);
1062+
if(cf) {
1063+
cf->connected = FALSE;
1064+
if(cf->ctx) {
1065+
h1_tunnel_go_state(cf, cf->ctx, H1_TUNNEL_INIT, data);
1066+
}
1067+
if(cf->next)
1068+
cf->next->cft->do_close(cf->next, data);
10631069
}
1064-
if(cf->next)
1065-
cf->next->cft->do_close(cf->next, data);
10661070
}
10671071

10681072

0 commit comments

Comments
 (0)