]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: quic: Possible memleak in qc_new_conn()
authorFrédéric Lécaille <flecaille@haproxy.com>
Wed, 2 Feb 2022 14:39:55 +0000 (15:39 +0100)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Mon, 14 Feb 2022 14:20:54 +0000 (15:20 +0100)
This should fix Coverity CID 375047 in GH #1536 where <buf_area> could leak because
not always freed by by quic_conn_drop(), especially when not stored in <qc> variable.

src/xprt_quic.c

index 29cffdeb13b18ff2b0e28c36bc1b11d69c2c7cfe..0793967b620cd057742d4557f4dc3427cdb3eed7 100644 (file)
@@ -3561,7 +3561,7 @@ static struct quic_conn *qc_new_conn(unsigned int version, int ipv4,
        struct quic_conn *qc;
        /* Initial CID. */
        struct quic_connection_id *icid;
-       char *buf_area;
+       char *buf_area = NULL;
        struct listener *l = NULL;
 
        TRACE_ENTER(QUIC_EV_CONN_INIT);
@@ -3668,6 +3668,9 @@ static struct quic_conn *qc_new_conn(unsigned int version, int ipv4,
 
  err:
        TRACE_DEVEL("leaving in error", QUIC_EV_CONN_INIT, qc ? qc : NULL);
+       pool_free(pool_head_quic_conn_rxbuf, buf_area);
+       if (qc)
+               qc->rx.buf.area = NULL;
        quic_conn_drop(qc);
        return NULL;
 }