Sanity check EVP_EncodeUpdate buffer len
[openssl.git] / crypto / evp / evp_enc.c
index 111351852e278f9249d60164b0409a707c03139f..3468b6b3fb570b3d0c9ec9aeac67993d02669d95 100644 (file)
@@ -227,7 +227,6 @@ int EVP_CipherInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,
 
         default:
             return 0;
-            break;
         }
     }
 
@@ -523,14 +522,15 @@ int EVP_DecryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl)
 
 void EVP_CIPHER_CTX_free(EVP_CIPHER_CTX *ctx)
 {
-    if (ctx) {
-        EVP_CIPHER_CTX_cleanup(ctx);
+    EVP_CIPHER_CTX_cleanup(ctx);
+    if (ctx)
         OPENSSL_free(ctx);
-    }
 }
 
 int EVP_CIPHER_CTX_cleanup(EVP_CIPHER_CTX *c)
 {
+    if (!c)
+        return 0;
     if (c->cipher != NULL) {
         if (c->cipher->cleanup && !c->cipher->cleanup(c))
             return 0;