ssl/ssl_lib.c:3201: error: NULL_DEREFERENCE
  pointer `ctx` last assigned on line 3192 could be null and is dereferenced by call to `EVP_MD_CTX_free()` at line 3201, column 5.
Showing all 37 steps of the trace


ssl/ssl_lib.c:3183:1: start of procedure ssl_handshake_hash()
3181.   
3182.   /* Retrieve handshake hashes */
3183. > int ssl_handshake_hash(SSL *s, unsigned char *out, int outlen)
3184.   {
3185.       EVP_MD_CTX *ctx = NULL;

ssl/ssl_lib.c:3185:5: 
3183.   int ssl_handshake_hash(SSL *s, unsigned char *out, int outlen)
3184.   {
3185. >     EVP_MD_CTX *ctx = NULL;
3186.       EVP_MD_CTX *hdgst = s->s3->handshake_dgst;
3187.       int ret = EVP_MD_CTX_size(hdgst);

ssl/ssl_lib.c:3186:5: 
3184.   {
3185.       EVP_MD_CTX *ctx = NULL;
3186. >     EVP_MD_CTX *hdgst = s->s3->handshake_dgst;
3187.       int ret = EVP_MD_CTX_size(hdgst);
3188.       if (ret < 0 || ret > outlen) {

ssl/ssl_lib.c:3187:5: 
3185.       EVP_MD_CTX *ctx = NULL;
3186.       EVP_MD_CTX *hdgst = s->s3->handshake_dgst;
3187. >     int ret = EVP_MD_CTX_size(hdgst);
3188.       if (ret < 0 || ret > outlen) {
3189.           ret = 0;

crypto/evp/evp_lib.c:436:1: start of procedure EVP_MD_CTX_md()
  434.   }
  435.   
  436. > const EVP_MD *EVP_MD_CTX_md(const EVP_MD_CTX *ctx)
  437.   {
  438.       if (!ctx)

crypto/evp/evp_lib.c:438:10: Taking false branch
  436.   const EVP_MD *EVP_MD_CTX_md(const EVP_MD_CTX *ctx)
  437.   {
  438.       if (!ctx)
                  ^
  439.           return NULL;
  440.       return ctx->digest;

crypto/evp/evp_lib.c:440:5: 
  438.       if (!ctx)
  439.           return NULL;
  440. >     return ctx->digest;
  441.   }
  442.   

crypto/evp/evp_lib.c:441:1: return from a call to EVP_MD_CTX_md
  439.           return NULL;
  440.       return ctx->digest;
  441. > }
  442.   
  443.   EVP_PKEY_CTX *EVP_MD_CTX_pkey_ctx(const EVP_MD_CTX *ctx)

crypto/evp/evp_lib.c:300:1: start of procedure EVP_MD_size()
  298.   }
  299.   
  300. > int EVP_MD_size(const EVP_MD *md)
  301.   {
  302.       if (!md) {

crypto/evp/evp_lib.c:302:10: Taking false branch
  300.   int EVP_MD_size(const EVP_MD *md)
  301.   {
  302.       if (!md) {
                  ^
  303.           EVPerr(EVP_F_EVP_MD_SIZE, EVP_R_MESSAGE_DIGEST_IS_NULL);
  304.           return -1;

crypto/evp/evp_lib.c:306:5: 
  304.           return -1;
  305.       }
  306. >     return md->md_size;
  307.   }
  308.   

crypto/evp/evp_lib.c:307:1: return from a call to EVP_MD_size
  305.       }
  306.       return md->md_size;
  307. > }
  308.   
  309.   unsigned long EVP_MD_flags(const EVP_MD *md)

ssl/ssl_lib.c:3188:9: Taking false branch
3186.       EVP_MD_CTX *hdgst = s->s3->handshake_dgst;
3187.       int ret = EVP_MD_CTX_size(hdgst);
3188.       if (ret < 0 || ret > outlen) {
                ^
3189.           ret = 0;
3190.           goto err;

ssl/ssl_lib.c:3188:20: Taking false branch
3186.       EVP_MD_CTX *hdgst = s->s3->handshake_dgst;
3187.       int ret = EVP_MD_CTX_size(hdgst);
3188.       if (ret < 0 || ret > outlen) {
                           ^
3189.           ret = 0;
3190.           goto err;

ssl/ssl_lib.c:3192:5: 
3190.           goto err;
3191.       }
3192. >     ctx = EVP_MD_CTX_new();
3193.       if (ctx == NULL) {
3194.           ret = 0;

crypto/evp/digest.c:153:1: start of procedure EVP_MD_CTX_new()
  151.   }
  152.   
  153. > EVP_MD_CTX *EVP_MD_CTX_new(void)
  154.   {
  155.       return OPENSSL_zalloc(sizeof(EVP_MD_CTX));

crypto/evp/digest.c:155:5: 
  153.   EVP_MD_CTX *EVP_MD_CTX_new(void)
  154.   {
  155. >     return OPENSSL_zalloc(sizeof(EVP_MD_CTX));
  156.   }
  157.   

crypto/mem.c:312:1: start of procedure CRYPTO_zalloc()
    310.   }
    311.   
    312. > void *CRYPTO_zalloc(size_t num, const char *file, int line)
    313.   {
    314.       void *ret = CRYPTO_malloc(num, file, line);

crypto/mem.c:314:5: 
    312.   void *CRYPTO_zalloc(size_t num, const char *file, int line)
    313.   {
    314. >     void *ret = CRYPTO_malloc(num, file, line);
    315.   
    316.       if (ret != NULL)

crypto/mem.c:279:1: start of procedure CRYPTO_malloc()
      277.   }
      278.   
      279. > void *CRYPTO_malloc(size_t num, const char *file, int line)
      280.   {
      281.       void *ret = NULL;

crypto/mem.c:281:5: 
      279.   void *CRYPTO_malloc(size_t num, const char *file, int line)
      280.   {
      281. >     void *ret = NULL;
      282.   
      283.       if (num <= 0)

crypto/mem.c:283:9: Taking false branch
      281.       void *ret = NULL;
      282.   
      283.       if (num <= 0)
                     ^
      284.           return NULL;
      285.   

crypto/mem.c:286:9: Taking true branch
      284.           return NULL;
      285.   
      286.       if (allow_customize)
                     ^
      287.           allow_customize = 0;
      288.       if (malloc_debug_func != NULL) {

crypto/mem.c:287:9: 
      285.   
      286.       if (allow_customize)
      287. >         allow_customize = 0;
      288.       if (malloc_debug_func != NULL) {
      289.           if (allow_customize_debug)

crypto/mem.c:288:9: Taking false branch
      286.       if (allow_customize)
      287.           allow_customize = 0;
      288.       if (malloc_debug_func != NULL) {
                     ^
      289.           if (allow_customize_debug)
      290.               allow_customize_debug = 0;

crypto/mem.c:293:5: Skipping __function_pointer__(): unresolved function pointer
      291.           malloc_debug_func(NULL, num, file, line, 0);
      292.       }
      293.       ret = malloc_ex_func(num, file, line);
                 ^
      294.       if (malloc_debug_func != NULL)
      295.           malloc_debug_func(ret, num, file, line, 1);

crypto/mem.c:294:9: Taking false branch
      292.       }
      293.       ret = malloc_ex_func(num, file, line);
      294.       if (malloc_debug_func != NULL)
                     ^
      295.           malloc_debug_func(ret, num, file, line, 1);
      296.   

crypto/mem.c:309:5: 
      307.   #endif
      308.   
      309. >     return ret;
      310.   }
      311.   

crypto/mem.c:310:1: return from a call to CRYPTO_malloc
      308.   
      309.       return ret;
      310. > }
      311.   
      312.   void *CRYPTO_zalloc(size_t num, const char *file, int line)

crypto/mem.c:316:9: Taking false branch
    314.       void *ret = CRYPTO_malloc(num, file, line);
    315.   
    316.       if (ret != NULL)
                   ^
    317.           memset(ret, 0, num);
    318.       return ret;

crypto/mem.c:318:5: 
    316.       if (ret != NULL)
    317.           memset(ret, 0, num);
    318. >     return ret;
    319.   }
    320.   

crypto/mem.c:319:1: return from a call to CRYPTO_zalloc
    317.           memset(ret, 0, num);
    318.       return ret;
    319. > }
    320.   
    321.   void *CRYPTO_realloc(void *str, size_t num, const char *file, int line)

crypto/evp/digest.c:156:1: return from a call to EVP_MD_CTX_new
  154.   {
  155.       return OPENSSL_zalloc(sizeof(EVP_MD_CTX));
  156. > }
  157.   
  158.   void EVP_MD_CTX_free(EVP_MD_CTX *ctx)

ssl/ssl_lib.c:3193:9: Taking true branch
3191.       }
3192.       ctx = EVP_MD_CTX_new();
3193.       if (ctx == NULL) {
                ^
3194.           ret = 0;
3195.           goto err;

ssl/ssl_lib.c:3194:9: 
3192.       ctx = EVP_MD_CTX_new();
3193.       if (ctx == NULL) {
3194. >         ret = 0;
3195.           goto err;
3196.       }

ssl/ssl_lib.c:3200:2: 
3198.           || EVP_DigestFinal_ex(ctx, out, NULL) <= 0)
3199.           ret = 0;
3200. >  err:
3201.       EVP_MD_CTX_free(ctx);
3202.       return ret;

ssl/ssl_lib.c:3201:5: 
3199.           ret = 0;
3200.    err:
3201. >     EVP_MD_CTX_free(ctx);
3202.       return ret;
3203.   }
