http2: pass stream to http2_handle_stream_close to avoid NULL checks

Closes #11005
This commit is contained in:
Stefan Eissing 2023-04-21 12:19:22 +02:00 committed by Daniel Stenberg
parent cab2d56ea5
commit fbea71f293
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2

View file

@ -1512,9 +1512,9 @@ out:
static ssize_t http2_handle_stream_close(struct Curl_cfilter *cf, static ssize_t http2_handle_stream_close(struct Curl_cfilter *cf,
struct Curl_easy *data, struct Curl_easy *data,
struct stream_ctx *stream,
CURLcode *err) CURLcode *err)
{ {
struct stream_ctx *stream = H2_STREAM_CTX(data);
ssize_t rv = 0; ssize_t rv = 0;
if(stream->error == NGHTTP2_REFUSED_STREAM) { if(stream->error == NGHTTP2_REFUSED_STREAM) {
@ -1675,7 +1675,7 @@ static ssize_t stream_recv(struct Curl_cfilter *cf, struct Curl_easy *data,
if(nread < 0) { if(nread < 0) {
if(stream->closed) { if(stream->closed) {
nread = http2_handle_stream_close(cf, data, err); nread = http2_handle_stream_close(cf, data, stream, err);
} }
else if(stream->reset || else if(stream->reset ||
(ctx->conn_closed && Curl_bufq_is_empty(&ctx->inbufq)) || (ctx->conn_closed && Curl_bufq_is_empty(&ctx->inbufq)) ||
@ -1975,7 +1975,7 @@ static ssize_t cf_h2_send(struct Curl_cfilter *cf, struct Curl_easy *data,
goto out; goto out;
} }
else if(stream->closed) { else if(stream->closed) {
nwritten = http2_handle_stream_close(cf, data, err); nwritten = http2_handle_stream_close(cf, data, stream, err);
goto out; goto out;
} }
/* If stream_id != -1, we have dispatched request HEADERS, and now /* If stream_id != -1, we have dispatched request HEADERS, and now
@ -2012,7 +2012,7 @@ static ssize_t cf_h2_send(struct Curl_cfilter *cf, struct Curl_easy *data,
if(should_close_session(ctx)) { if(should_close_session(ctx)) {
if(stream->closed) { if(stream->closed) {
nwritten = http2_handle_stream_close(cf, data, err); nwritten = http2_handle_stream_close(cf, data, stream, err);
} }
else { else {
DEBUGF(LOG_CF(data, cf, "send: nothing to do in this session")); DEBUGF(LOG_CF(data, cf, "send: nothing to do in this session"));
@ -2062,7 +2062,7 @@ static ssize_t cf_h2_send(struct Curl_cfilter *cf, struct Curl_easy *data,
if(should_close_session(ctx)) { if(should_close_session(ctx)) {
if(stream->closed) { if(stream->closed) {
nwritten = http2_handle_stream_close(cf, data, err); nwritten = http2_handle_stream_close(cf, data, stream, err);
} }
else { else {
DEBUGF(LOG_CF(data, cf, "send: nothing to do in this session")); DEBUGF(LOG_CF(data, cf, "send: nothing to do in this session"));