crypto/x509/x509_cmp.c:107: error: NULL_DEREFERENCE
  pointer `ctx` last assigned on line 85 could be null and is dereferenced by call to `EVP_MD_CTX_free()` at line 107, column 5.
Showing all 23 steps of the trace


crypto/x509/x509_cmp.c:82:1: start of procedure X509_issuer_and_serial_hash()
80.   
81.   #ifndef OPENSSL_NO_MD5
82. > unsigned long X509_issuer_and_serial_hash(X509 *a)
83.   {
84.       unsigned long ret = 0;

crypto/x509/x509_cmp.c:84:5: 
82.   unsigned long X509_issuer_and_serial_hash(X509 *a)
83.   {
84. >     unsigned long ret = 0;
85.       EVP_MD_CTX *ctx = EVP_MD_CTX_new();
86.       unsigned char md[16];

crypto/x509/x509_cmp.c:85:5: 
83.   {
84.       unsigned long ret = 0;
85. >     EVP_MD_CTX *ctx = EVP_MD_CTX_new();
86.       unsigned char md[16];
87.       char *f;

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 false branch
      284.           return NULL;
      285.   
      286.       if (allow_customize)
                     ^
      287.           allow_customize = 0;
      288.       if (malloc_debug_func != NULL) {

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)

crypto/x509/x509_cmp.c:89:9: Taking true branch
87.       char *f;
88.   
89.       if (ctx == NULL)
              ^
90.           goto err;
91.       f = X509_NAME_oneline(a->cert_info.issuer, NULL, 0);

crypto/x509/x509_cmp.c:106:2: 
104.              ((unsigned long)md[2] << 16L) | ((unsigned long)md[3] << 24L)
105.           ) & 0xffffffffL;
106. >  err:
107.       EVP_MD_CTX_free(ctx);
108.       return (ret);

crypto/x509/x509_cmp.c:107:5: 
105.           ) & 0xffffffffL;
106.    err:
107. >     EVP_MD_CTX_free(ctx);
108.       return (ret);
109.   }

unsigned long X509_issuer_and_serial_hash(X509 *a)
{
    unsigned long ret = 0;
    EVP_MD_CTX *ctx = EVP_MD_CTX_new();
    unsigned char md[16];
    char *f;
    if (ctx == NULL)
        goto err;
    f = X509_NAME_oneline(a->cert_info.issuer, NULL, 0);
    if (!EVP_DigestInit_ex(ctx, EVP_md5(), NULL))
        goto err;
    if (!EVP_DigestUpdate(ctx, (unsigned char *)f, strlen(f)))
        goto err;
    OPENSSL_free(f);
    if (!EVP_DigestUpdate
        (ctx, (unsigned char *)a->cert_info.serialNumber.data,
         (unsigned long)a->cert_info.serialNumber.length))
        goto err;
    if (!EVP_DigestFinal_ex(ctx, &(md[0]), NULL))
        goto err;
    ret = (((unsigned long)md[0]) | ((unsigned long)md[1] << 8L) |
           ((unsigned long)md[2] << 16L) | ((unsigned long)md[3] << 24L)
        ) & 0xffffffffL;
 err:
    EVP_MD_CTX_free(ctx);
    return (ret);
}
['unsigned long X509_issuer_and_serial_hash(X509 *a)\n{\n    unsigned long ret = 0;\n    EVP_MD_CTX *ctx = EVP_MD_CTX_new();\n    unsigned char md[16];\n    char *f;\n    if (ctx == NULL)\n        goto err;\n    f = X509_NAME_oneline(a->cert_info.issuer, NULL, 0);\n    if (!EVP_DigestInit_ex(ctx, EVP_md5(), NULL))\n        goto err;\n    if (!EVP_DigestUpdate(ctx, (unsigned char *)f, strlen(f)))\n        goto err;\n    OPENSSL_free(f);\n    if (!EVP_DigestUpdate\n        (ctx, (unsigned char *)a->cert_info.serialNumber.data,\n         (unsigned long)a->cert_info.serialNumber.length))\n        goto err;\n    if (!EVP_DigestFinal_ex(ctx, &(md[0]), NULL))\n        goto err;\n    ret = (((unsigned long)md[0]) | ((unsigned long)md[1] << 8L) |\n           ((unsigned long)md[2] << 16L) | ((unsigned long)md[3] << 24L)\n        ) & 0xffffffffL;\n err:\n    EVP_MD_CTX_free(ctx);\n    return (ret);\n}', 'EVP_MD_CTX *EVP_MD_CTX_new(void)\n{\n    return OPENSSL_zalloc(sizeof(EVP_MD_CTX));\n}', 'void *CRYPTO_zalloc(size_t num, const char *file, int line)\n{\n    void *ret = CRYPTO_malloc(num, file, line);\n    if (ret != NULL)\n        memset(ret, 0, num);\n    return ret;\n}', 'void *CRYPTO_malloc(size_t num, const char *file, int line)\n{\n    void *ret = NULL;\n    if (num <= 0)\n        return NULL;\n    if (allow_customize)\n        allow_customize = 0;\n    if (malloc_debug_func != NULL) {\n        if (allow_customize_debug)\n            allow_customize_debug = 0;\n        malloc_debug_func(NULL, num, file, line, 0);\n    }\n    ret = malloc_ex_func(num, file, line);\n    if (malloc_debug_func != NULL)\n        malloc_debug_func(ret, num, file, line, 1);\n#ifndef OPENSSL_CPUID_OBJ\n    if (ret && (num > 2048)) {\n        extern unsigned char cleanse_ctr;\n        ((unsigned char *)ret)[0] = cleanse_ctr;\n    }\n#endif\n    return ret;\n}']