crypto/evp/cmeth_lib.c:81: error: NULL_DEREFERENCE
  pointer `to` last assigned on line 78 could be null and is dereferenced by call to `memcpy()` at line 81, column 9.
Showing all 23 steps of the trace


crypto/evp/cmeth_lib.c:76:1: start of procedure EVP_CIPHER_meth_dup()
74.   }
75.   
76. > EVP_CIPHER *EVP_CIPHER_meth_dup(const EVP_CIPHER *cipher)
77.   {
78.       EVP_CIPHER *to = EVP_CIPHER_meth_new(cipher->nid, cipher->block_size,

crypto/evp/cmeth_lib.c:78:5: 
76.   EVP_CIPHER *EVP_CIPHER_meth_dup(const EVP_CIPHER *cipher)
77.   {
78. >     EVP_CIPHER *to = EVP_CIPHER_meth_new(cipher->nid, cipher->block_size,
79.                                            cipher->key_len);
80.       if (cipher != NULL)

crypto/evp/cmeth_lib.c:65:1: start of procedure EVP_CIPHER_meth_new()
  63.   #include "evp_locl.h"
  64.   
  65. > EVP_CIPHER *EVP_CIPHER_meth_new(int cipher_type, int block_size, int key_len)
  66.   {
  67.       EVP_CIPHER *cipher = (EVP_CIPHER *)OPENSSL_zalloc(sizeof(EVP_CIPHER));

crypto/evp/cmeth_lib.c:67:5: 
  65.   EVP_CIPHER *EVP_CIPHER_meth_new(int cipher_type, int block_size, int key_len)
  66.   {
  67. >     EVP_CIPHER *cipher = (EVP_CIPHER *)OPENSSL_zalloc(sizeof(EVP_CIPHER));
  68.       if (cipher != NULL) {
  69.           cipher->nid = cipher_type;

crypto/mem.c:156:1: start of procedure CRYPTO_zalloc()
    154.   }
    155.   
    156. > void *CRYPTO_zalloc(size_t num, const char *file, int line)
    157.   {
    158.       void *ret = CRYPTO_malloc(num, file, line);

crypto/mem.c:158:5: 
    156.   void *CRYPTO_zalloc(size_t num, const char *file, int line)
    157.   {
    158. >     void *ret = CRYPTO_malloc(num, file, line);
    159.   
    160.       if (ret != NULL)

crypto/mem.c:119:1: start of procedure CRYPTO_malloc()
      117.   }
      118.   
      119. > void *CRYPTO_malloc(size_t num, const char *file, int line)
      120.   {
      121.       void *ret = NULL;

crypto/mem.c:121:5: 
      119.   void *CRYPTO_malloc(size_t num, const char *file, int line)
      120.   {
      121. >     void *ret = NULL;
      122.   
      123.       if (num <= 0)

crypto/mem.c:123:9: Taking false branch
      121.       void *ret = NULL;
      122.   
      123.       if (num <= 0)
                     ^
      124.           return NULL;
      125.   

crypto/mem.c:126:5: 
      124.           return NULL;
      125.   
      126. >     allow_customize = 0;
      127.   #ifndef OPENSSL_NO_CRYPTO_MDEBUG
      128.       if (call_malloc_debug) {

crypto/mem.c:136:5: 
      134.       }
      135.   #else
      136. >     (void)file;
      137.       (void)line;
      138.       ret = malloc(num);

crypto/mem.c:137:5: 
      135.   #else
      136.       (void)file;
      137. >     (void)line;
      138.       ret = malloc(num);
      139.   #endif

crypto/mem.c:138:5: 
      136.       (void)file;
      137.       (void)line;
      138. >     ret = malloc(num);
      139.   #endif
      140.   

crypto/mem.c:153:5: 
      151.   #endif
      152.   
      153. >     return ret;
      154.   }
      155.   

crypto/mem.c:154:1: return from a call to CRYPTO_malloc
      152.   
      153.       return ret;
      154. > }
      155.   
      156.   void *CRYPTO_zalloc(size_t num, const char *file, int line)

crypto/mem.c:160:9: Taking false branch
    158.       void *ret = CRYPTO_malloc(num, file, line);
    159.   
    160.       if (ret != NULL)
                   ^
    161.           memset(ret, 0, num);
    162.       return ret;

crypto/mem.c:162:5: 
    160.       if (ret != NULL)
    161.           memset(ret, 0, num);
    162. >     return ret;
    163.   }
    164.   

crypto/mem.c:163:1: return from a call to CRYPTO_zalloc
    161.           memset(ret, 0, num);
    162.       return ret;
    163. > }
    164.   
    165.   void *CRYPTO_realloc(void *str, size_t num, const char *file, int line)

crypto/evp/cmeth_lib.c:68:9: Taking false branch
  66.   {
  67.       EVP_CIPHER *cipher = (EVP_CIPHER *)OPENSSL_zalloc(sizeof(EVP_CIPHER));
  68.       if (cipher != NULL) {
                ^
  69.           cipher->nid = cipher_type;
  70.           cipher->block_size = block_size;

crypto/evp/cmeth_lib.c:73:5: 
  71.           cipher->key_len = key_len;
  72.       }
  73. >     return cipher;
  74.   }
  75.   

crypto/evp/cmeth_lib.c:74:1: return from a call to EVP_CIPHER_meth_new
  72.       }
  73.       return cipher;
  74. > }
  75.   
  76.   EVP_CIPHER *EVP_CIPHER_meth_dup(const EVP_CIPHER *cipher)

crypto/evp/cmeth_lib.c:80:9: Taking true branch
78.       EVP_CIPHER *to = EVP_CIPHER_meth_new(cipher->nid, cipher->block_size,
79.                                            cipher->key_len);
80.       if (cipher != NULL)
              ^
81.           memcpy(to, cipher, sizeof(*to));
82.       return to;

crypto/evp/cmeth_lib.c:81:9: 
79.                                            cipher->key_len);
80.       if (cipher != NULL)
81. >         memcpy(to, cipher, sizeof(*to));
82.       return to;
83.   }
