From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44792) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZDDGI-0005Wz-Ed for qemu-devel@nongnu.org; Thu, 09 Jul 2015 10:57:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZDDGF-0002oM-KH for qemu-devel@nongnu.org; Thu, 09 Jul 2015 10:57:18 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54712) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZDDGF-0002oI-FD for qemu-devel@nongnu.org; Thu, 09 Jul 2015 10:57:15 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id F36042D4512 for ; Thu, 9 Jul 2015 14:57:14 +0000 (UTC) Received: from donizetti.redhat.com (ovpn-112-32.ams2.redhat.com [10.36.112.32]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t69EvA2e023353 for ; Thu, 9 Jul 2015 10:57:14 -0400 From: Paolo Bonzini Date: Thu, 9 Jul 2015 16:57:10 +0200 Message-Id: <1436453830-4700-3-git-send-email-pbonzini@redhat.com> In-Reply-To: <1436453830-4700-1-git-send-email-pbonzini@redhat.com> References: <1436453830-4700-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PULL 2/2] crypto: fix builtin qcrypto_cipher_free List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org This was dereferencing a pointer before checking if it was NULL. Reported-by: Christian Borntraeger Reported-by: Aurelien Jarno Signed-off-by: Paolo Bonzini --- crypto/cipher-builtin.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crypto/cipher-builtin.c b/crypto/cipher-builtin.c index c625cb4..912c1b9 100644 --- a/crypto/cipher-builtin.c +++ b/crypto/cipher-builtin.c @@ -354,11 +354,13 @@ QCryptoCipher *qcrypto_cipher_new(QCryptoCipherAlgorithm alg, void qcrypto_cipher_free(QCryptoCipher *cipher) { - QCryptoCipherBuiltin *ctxt = cipher->opaque; + QCryptoCipherBuiltin *ctxt; + if (!cipher) { return; } + ctxt = cipher->opaque; ctxt->free(cipher); g_free(cipher); } -- 2.4.3