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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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