From: Paolo Bonzini Date: Thu, 9 Jul 2015 14:52:48 +0000 (+0200) Subject: crypto: fix builtin qcrypto_cipher_free X-Git-Tag: v2.4.0-rc0~2^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4f4f6976d80614e2d81cea4385885876f24bb257;p=thirdparty%2Fqemu.git crypto: fix builtin qcrypto_cipher_free This was dereferencing a pointer before checking if it was NULL. Reported-by: Christian Borntraeger Reported-by: Aurelien Jarno Signed-off-by: Paolo Bonzini --- diff --git a/crypto/cipher-builtin.c b/crypto/cipher-builtin.c index c625cb40f76..912c1b947db 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); }