crypto/evp/cmeth_lib.c:42: error: NULL_DEREFERENCE
  pointer `to` last assigned on line 40 could be null and is dereferenced at line 42, column 31.
Showing all 11 steps of the trace


crypto/evp/cmeth_lib.c:29:1: start of procedure EVP_CIPHER_meth_dup()
27.   }
28.   
29. > EVP_CIPHER *EVP_CIPHER_meth_dup(const EVP_CIPHER *cipher)
30.   {
31.       EVP_CIPHER *to = NULL;

crypto/evp/cmeth_lib.c:31:5: 
29.   EVP_CIPHER *EVP_CIPHER_meth_dup(const EVP_CIPHER *cipher)
30.   {
31. >     EVP_CIPHER *to = NULL;
32.   
33.       /*

crypto/evp/cmeth_lib.c:37:9: Taking false branch
35.        * Use EVP_CIPHER_up_ref() instead.
36.        */
37.       if (cipher->prov != NULL)
              ^
38.           return NULL;
39.   

crypto/evp/cmeth_lib.c:40:9: 
38.           return NULL;
39.   
40. >     if ((to = EVP_CIPHER_meth_new(cipher->nid, cipher->block_size,
41.                                     cipher->key_len)) == NULL) {
42.           CRYPTO_RWLOCK *lock = to->lock;

crypto/evp/cmeth_lib.c:17:1: start of procedure EVP_CIPHER_meth_new()
  15.   #include "evp_locl.h"
  16.   
  17. > EVP_CIPHER *EVP_CIPHER_meth_new(int cipher_type, int block_size, int key_len)
  18.   {
  19.       EVP_CIPHER *cipher = evp_cipher_new();

crypto/evp/cmeth_lib.c:19:5: Skipping evp_cipher_new(): empty list of specs
  17.   EVP_CIPHER *EVP_CIPHER_meth_new(int cipher_type, int block_size, int key_len)
  18.   {
  19.       EVP_CIPHER *cipher = evp_cipher_new();
            ^
  20.   
  21.       if (cipher != NULL) {

crypto/evp/cmeth_lib.c:21:9: Taking false branch
  19.       EVP_CIPHER *cipher = evp_cipher_new();
  20.   
  21.       if (cipher != NULL) {
                ^
  22.           cipher->nid = cipher_type;
  23.           cipher->block_size = block_size;

crypto/evp/cmeth_lib.c:26:5: 
  24.           cipher->key_len = key_len;
  25.       }
  26. >     return cipher;
  27.   }
  28.   

crypto/evp/cmeth_lib.c:27:1: return from a call to EVP_CIPHER_meth_new
  25.       }
  26.       return cipher;
  27. > }
  28.   
  29.   EVP_CIPHER *EVP_CIPHER_meth_dup(const EVP_CIPHER *cipher)

crypto/evp/cmeth_lib.c:40:9: Taking true branch
38.           return NULL;
39.   
40.       if ((to = EVP_CIPHER_meth_new(cipher->nid, cipher->block_size,
              ^
41.                                     cipher->key_len)) == NULL) {
42.           CRYPTO_RWLOCK *lock = to->lock;

crypto/evp/cmeth_lib.c:42:9: 
40.       if ((to = EVP_CIPHER_meth_new(cipher->nid, cipher->block_size,
41.                                     cipher->key_len)) == NULL) {
42. >         CRYPTO_RWLOCK *lock = to->lock;
43.   
44.           memcpy(to, cipher, sizeof(*to));

EVP_CIPHER *EVP_CIPHER_meth_dup(const EVP_CIPHER *cipher)
{
    EVP_CIPHER *to = NULL;
    if (cipher->prov != NULL)
        return NULL;
    if ((to = EVP_CIPHER_meth_new(cipher->nid, cipher->block_size,
                                  cipher->key_len)) == NULL) {
        CRYPTO_RWLOCK *lock = to->lock;
        memcpy(to, cipher, sizeof(*to));
        to->lock = lock;
    }
    return to;
}
['EVP_CIPHER *EVP_CIPHER_meth_dup(const EVP_CIPHER *cipher)\n{\n    EVP_CIPHER *to = NULL;\n    if (cipher->prov != NULL)\n        return NULL;\n    if ((to = EVP_CIPHER_meth_new(cipher->nid, cipher->block_size,\n                                  cipher->key_len)) == NULL) {\n        CRYPTO_RWLOCK *lock = to->lock;\n        memcpy(to, cipher, sizeof(*to));\n        to->lock = lock;\n    }\n    return to;\n}', 'EVP_CIPHER *EVP_CIPHER_meth_new(int cipher_type, int block_size, int key_len)\n{\n    EVP_CIPHER *cipher = evp_cipher_new();\n    if (cipher != NULL) {\n        cipher->nid = cipher_type;\n        cipher->block_size = block_size;\n        cipher->key_len = key_len;\n    }\n    return cipher;\n}']