From: Viktor Szakats Date: Sun, 20 Apr 2025 08:13:52 +0000 (+0200) Subject: openssl-quic: avoid potential `-Wnull-dereference`, add assert X-Git-Tag: curl-8_14_0~242 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d60c9aec420704ce31dbb9905d3188eab9bd2cbe;p=thirdparty%2Fcurl.git openssl-quic: avoid potential `-Wnull-dereference`, add assert Seen with curl-for-win, OpenSSL QUIC, gcc 14.2.0, cmake unity mode. Silences: ``` In file included from _x86-win-ucrt-bld/lib/CMakeFiles/libcurl_object.dir/Unity/unity_5_c.c:55: In function 'cf_osslq_check_and_unblock', inlined from 'cf_progress_egress' at lib/vquic/curl_osslq.c:1730:12: lib/vquic/curl_osslq.c:1581:11: error: potential null pointer dereference [-Werror=null-dereference] 1581 | nghttp3_conn_unblock_stream(ctx->h3.conn, stream->s.id); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ lib/vquic/curl_osslq.c:1582:34: error: potential null pointer dereference [-Werror=null-dereference] 1582 | stream->s.send_blocked = FALSE; | ^ ``` Co-authored-by: Daniel Stenberg Co-authored-by: Stefan Eissing Closes #17107 --- diff --git a/lib/vquic/curl_osslq.c b/lib/vquic/curl_osslq.c index 0603b1ab9c..1e5d153cd7 100644 --- a/lib/vquic/curl_osslq.c +++ b/lib/vquic/curl_osslq.c @@ -1564,10 +1564,13 @@ static CURLcode cf_osslq_check_and_unblock(struct Curl_cfilter *cf, idx_count++) { if(ctx->poll_items[idx_count].revents & SSL_POLL_EVENT_W) { stream = H3_STREAM_CTX(ctx, ctx->curl_items[idx_count]); - nghttp3_conn_unblock_stream(ctx->h3.conn, stream->s.id); - stream->s.send_blocked = FALSE; - h3_drain_stream(cf, ctx->curl_items[idx_count]); - CURL_TRC_CF(ctx->curl_items[idx_count], cf, "unblocked"); + DEBUGASSERT(stream); /* should still exist */ + if(stream) { + nghttp3_conn_unblock_stream(ctx->h3.conn, stream->s.id); + stream->s.send_blocked = FALSE; + h3_drain_stream(cf, ctx->curl_items[idx_count]); + CURL_TRC_CF(ctx->curl_items[idx_count], cf, "unblocked"); + } result_count--; } }