diff --git a/lib/vquic/curl_ngtcp2.c b/lib/vquic/curl_ngtcp2.c index 50dd873767..3f1179b2dd 100644 --- a/lib/vquic/curl_ngtcp2.c +++ b/lib/vquic/curl_ngtcp2.c @@ -1282,7 +1282,7 @@ static CURLcode cf_ngtcp2_recv(struct Curl_cfilter *cf, struct Curl_easy *data, struct h3_stream_ctx *stream = H3_STREAM_CTX(ctx, data); struct cf_call_data save; struct pkt_io_ctx pktx; - CURLcode result = CURLE_OK; + CURLcode result = CURLE_OK, r2; (void)ctx; (void)buf; @@ -1325,15 +1325,15 @@ static CURLcode cf_ngtcp2_recv(struct Curl_cfilter *cf, struct Curl_easy *data, result = CURLE_AGAIN; out: - if(cf_progress_egress(cf, data, &pktx)) { - result = CURLE_SEND_ERROR; - } - else { - CURLcode r2 = check_and_set_expiry(cf, data, &pktx); - if(r2) - result = r2; - } + /* do not replace `result` unless we have an error here */ + r2 = cf_progress_egress(cf, data, &pktx); + if(r2) + result = r2; + r2 = check_and_set_expiry(cf, data, &pktx); + if(r2) + result = r2; CURL_TRC_CF(data, cf, "[%" FMT_PRId64 "] cf_recv(blen=%zu) -> %dm, %zu", + stream ? stream->id : -1, blen, result, *pnread); CF_DATA_RESTORE(cf, save); return result; @@ -1595,10 +1595,9 @@ static CURLcode cf_ngtcp2_send(struct Curl_cfilter *cf, struct Curl_easy *data, return ctx->tls_vrfy_result; (void)eos; /* use for stream EOF and block handling */ - r2 = cf_progress_ingress(cf, data, &pktx); - if(r2) { - result = r2; - } + result = cf_progress_ingress(cf, data, &pktx); + if(result) + goto out; if(!stream || stream->id < 0) { if(ctx->shutdown_started) { @@ -1655,11 +1654,11 @@ static CURLcode cf_ngtcp2_send(struct Curl_cfilter *cf, struct Curl_easy *data, if(*pnwritten > 0 && !ctx->tls_handshake_complete && ctx->use_earlydata) ctx->earlydata_skip += *pnwritten; - r2 = cf_progress_egress(cf, data, &pktx); - if(r2) - result = r2; + DEBUGASSERT(!result); + result = cf_progress_egress(cf, data, &pktx); out: + /* do not overwrite `result` unless there is an error */ r2 = check_and_set_expiry(cf, data, &pktx); if(r2) result = r2;