crypto: fix builtin qcrypto_cipher_free
authorPaolo Bonzini <pbonzini@redhat.com>
Thu, 9 Jul 2015 14:52:48 +0000 (16:52 +0200)
committerPaolo Bonzini <pbonzini@redhat.com>
Thu, 9 Jul 2015 14:53:45 +0000 (16:53 +0200)
This was dereferencing a pointer before checking if it was NULL.

Reported-by: Christian Borntraeger <borntraeger@de.ibm.com>
Reported-by: Aurelien Jarno <aurelien@aurel32.net>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
crypto/cipher-builtin.c

index c625cb40f768542b3fa8c18738ffacb2bae1da09..912c1b947dbe03630ebc63fadec9404644b2c8e1 100644 (file)
@@ -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);
 }