BUILD: ssl: avoid a wrong null deref warning in ssl_sock_handshake

When disabling traces, "conn" isn't used between ctx assignment and its
first usage, and as usual, gcc wrongly believes that a null check in a
shared function implies the checked argument may be NULL where it's used,
leading to this warning:

  src/ssl_sock.c: In function 'ssl_sock_handshake.constprop':
  src/ssl_sock.c:6049:7: warning: null pointer dereference [-Wnull-dereference]

Assigning ctx after the conn_ctrl_ready() check is sufficient to shut it
up, so let's do this. It should also result in slightly better code.
This commit is contained in:
Willy Tarreau 2026-07-01 14:28:18 +02:00
parent b17a16b3e2
commit fa8ca0be4d

View file

@ -6037,7 +6037,7 @@ void ssl_sock_handle_hs_error(struct connection *conn)
*/
static int ssl_sock_handshake(struct connection *conn, unsigned int flag)
{
struct ssl_sock_ctx *ctx = conn_get_ssl_sock_ctx(conn);
struct ssl_sock_ctx *ctx;
int ret;
struct ssl_counters *counters = NULL;
struct ssl_counters *counters_px = NULL;
@ -6049,6 +6049,7 @@ static int ssl_sock_handshake(struct connection *conn, unsigned int flag)
if (!conn_ctrl_ready(conn))
return 0;
ctx = conn_get_ssl_sock_ctx(conn);
if (!ctx)
goto out_error;