]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-smtp: client: transaction: Prevent NULL dereference in smtp_client_transaction_un...
authorStephan Bosch <stephan.bosch@dovecot.fi>
Sun, 13 Jan 2019 22:17:54 +0000 (23:17 +0100)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Wed, 5 Feb 2020 13:16:02 +0000 (13:16 +0000)
The trans pointer is used before it is checked for being NULL, which is allowed
for this function.

Problem found by Coverity.

src/lib-smtp/smtp-client-transaction.c

index 225d9f5ff06c7fef4947041cede0ef7a28de4487..7ed87842449fdaf722ec4bf4549cefc5af0fc8f4 100644 (file)
@@ -603,12 +603,13 @@ void smtp_client_transaction_ref(struct smtp_client_transaction *trans)
 void smtp_client_transaction_unref(struct smtp_client_transaction **_trans)
 {
        struct smtp_client_transaction *trans = *_trans;
-       struct smtp_client_connection *conn = trans->conn;
+       struct smtp_client_connection *conn;
 
        *_trans = NULL;
 
        if (trans == NULL)
                return;
+       conn = trans->conn;
 
        i_assert(trans->refcount > 0);
        if (--trans->refcount > 0)