crypto/ocsp/ocsp_vfy.c:400: error: MEMORY_LEAK
  memory dynamically allocated by call to `X509_STORE_CTX_new()` at line 335, column 27 is not reachable after line 400, column 5.
Showing all 42 steps of the trace


crypto/ocsp/ocsp_vfy.c:328:1: start of procedure OCSP_request_verify()
326.    */
327.   
328. > int OCSP_request_verify(OCSP_REQUEST *req, STACK_OF(X509) *certs,
329.                           X509_STORE *store, unsigned long flags)
330.   {

crypto/ocsp/ocsp_vfy.c:334:5: 
332.       X509_NAME *nm;
333.       GENERAL_NAME *gen;
334. >     int ret = 0;
335.       X509_STORE_CTX *ctx = X509_STORE_CTX_new();
336.   

crypto/ocsp/ocsp_vfy.c:335:5: 
333.       GENERAL_NAME *gen;
334.       int ret = 0;
335. >     X509_STORE_CTX *ctx = X509_STORE_CTX_new();
336.   
337.       if (ctx == NULL) {

crypto/x509/x509_vfy.c:2201:1: start of procedure X509_STORE_CTX_new()
  2199.   }
  2200.   
  2201. > X509_STORE_CTX *X509_STORE_CTX_new(void)
  2202.   {
  2203.       X509_STORE_CTX *ctx = OPENSSL_zalloc(sizeof(*ctx));

crypto/x509/x509_vfy.c:2203:5: 
  2201.   X509_STORE_CTX *X509_STORE_CTX_new(void)
  2202.   {
  2203. >     X509_STORE_CTX *ctx = OPENSSL_zalloc(sizeof(*ctx));
  2204.   
  2205.       if (ctx == NULL) {

crypto/mem.c:186:1: start of procedure CRYPTO_zalloc()
    184.   }
    185.   
    186. > void *CRYPTO_zalloc(size_t num, const char *file, int line)
    187.   {
    188.       void *ret = CRYPTO_malloc(num, file, line);

crypto/mem.c:188:5: 
    186.   void *CRYPTO_zalloc(size_t num, const char *file, int line)
    187.   {
    188. >     void *ret = CRYPTO_malloc(num, file, line);
    189.   
    190.       FAILTEST();

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

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

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

crypto/mem.c:165:9: Taking false branch
      163.           return malloc_impl(num, file, line);
      164.   
      165.       if (num == 0)
                     ^
      166.           return NULL;
      167.   

crypto/mem.c:169:5: 
      167.   
      168.       FAILTEST();
      169. >     allow_customize = 0;
      170.   #ifndef OPENSSL_NO_CRYPTO_MDEBUG
      171.       if (call_malloc_debug) {

crypto/mem.c:179:5: 
      177.       }
      178.   #else
      179. >     osslargused(file); osslargused(line);
      180.       ret = malloc(num);
      181.   #endif

crypto/mem.c:179:24: 
      177.       }
      178.   #else
      179. >     osslargused(file); osslargused(line);
      180.       ret = malloc(num);
      181.   #endif

crypto/mem.c:180:5: 
      178.   #else
      179.       osslargused(file); osslargused(line);
      180. >     ret = malloc(num);
      181.   #endif
      182.   

crypto/mem.c:183:5: 
      181.   #endif
      182.   
      183. >     return ret;
      184.   }
      185.   

crypto/mem.c:184:1: return from a call to CRYPTO_malloc
      182.   
      183.       return ret;
      184. > }
      185.   
      186.   void *CRYPTO_zalloc(size_t num, const char *file, int line)

crypto/mem.c:191:9: Taking true branch
    189.   
    190.       FAILTEST();
    191.       if (ret != NULL)
                   ^
    192.           memset(ret, 0, num);
    193.       return ret;

crypto/mem.c:192:9: 
    190.       FAILTEST();
    191.       if (ret != NULL)
    192. >         memset(ret, 0, num);
    193.       return ret;
    194.   }

crypto/mem.c:193:5: 
    191.       if (ret != NULL)
    192.           memset(ret, 0, num);
    193. >     return ret;
    194.   }
    195.   

crypto/mem.c:194:1: return from a call to CRYPTO_zalloc
    192.           memset(ret, 0, num);
    193.       return ret;
    194. > }
    195.   
    196.   void *CRYPTO_realloc(void *str, size_t num, const char *file, int line)

crypto/x509/x509_vfy.c:2205:9: Taking false branch
  2203.       X509_STORE_CTX *ctx = OPENSSL_zalloc(sizeof(*ctx));
  2204.   
  2205.       if (ctx == NULL) {
                  ^
  2206.           X509err(X509_F_X509_STORE_CTX_NEW, ERR_R_MALLOC_FAILURE);
  2207.           return NULL;

crypto/x509/x509_vfy.c:2209:5: 
  2207.           return NULL;
  2208.       }
  2209. >     return ctx;
  2210.   }
  2211.   

crypto/x509/x509_vfy.c:2210:1: return from a call to X509_STORE_CTX_new
  2208.       }
  2209.       return ctx;
  2210. > }
  2211.   
  2212.   void X509_STORE_CTX_free(X509_STORE_CTX *ctx)

crypto/ocsp/ocsp_vfy.c:337:9: Taking false branch
335.       X509_STORE_CTX *ctx = X509_STORE_CTX_new();
336.   
337.       if (ctx == NULL) {
               ^
338.           OCSPerr(OCSP_F_OCSP_REQUEST_VERIFY, ERR_R_MALLOC_FAILURE);
339.           goto err;

crypto/ocsp/ocsp_vfy.c:342:10: Taking true branch
340.       }
341.   
342.       if (!req->optionalSignature) {
                ^
343.           OCSPerr(OCSP_F_OCSP_REQUEST_VERIFY, OCSP_R_REQUEST_NOT_SIGNED);
344.           goto err;

crypto/ocsp/ocsp_vfy.c:343:9: Skipping ERR_put_error(): empty list of specs
341.   
342.       if (!req->optionalSignature) {
343.           OCSPerr(OCSP_F_OCSP_REQUEST_VERIFY, OCSP_R_REQUEST_NOT_SIGNED);
               ^
344.           goto err;
345.       }

crypto/ocsp/ocsp_vfy.c:397:1: 
395.       goto end;
396.   
397. > err:
398.       ret = 0;
399.   end:

crypto/ocsp/ocsp_vfy.c:398:5: 
396.   
397.   err:
398. >     ret = 0;
399.   end:
400.       X509_STORE_CTX_free(ctx);

crypto/ocsp/ocsp_vfy.c:399:1: 
397.   err:
398.       ret = 0;
399. > end:
400.       X509_STORE_CTX_free(ctx);
401.       return ret;

crypto/ocsp/ocsp_vfy.c:400:5: 
398.       ret = 0;
399.   end:
400. >     X509_STORE_CTX_free(ctx);
401.       return ret;
402.   

crypto/x509/x509_vfy.c:2212:1: start of procedure X509_STORE_CTX_free()
  2210.   }
  2211.   
  2212. > void X509_STORE_CTX_free(X509_STORE_CTX *ctx)
  2213.   {
  2214.       if (ctx == NULL)

crypto/x509/x509_vfy.c:2214:9: Taking false branch
  2212.   void X509_STORE_CTX_free(X509_STORE_CTX *ctx)
  2213.   {
  2214.       if (ctx == NULL)
                  ^
  2215.           return;
  2216.   

crypto/x509/x509_vfy.c:2217:5: Skipping X509_STORE_CTX_cleanup(): empty list of specs
  2215.           return;
  2216.   
  2217.       X509_STORE_CTX_cleanup(ctx);
              ^
  2218.       OPENSSL_free(ctx);
  2219.   }

crypto/x509/x509_vfy.c:2218:5: 
  2216.   
  2217.       X509_STORE_CTX_cleanup(ctx);
  2218. >     OPENSSL_free(ctx);
  2219.   }
  2220.   

crypto/mem.c:253:1: start of procedure CRYPTO_free()
    251.   }
    252.   
    253. > void CRYPTO_free(void *str, const char *file, int line)
    254.   {
    255.       if (free_impl != NULL && free_impl != &CRYPTO_free) {

crypto/mem.c:255:9: Taking true branch
    253.   void CRYPTO_free(void *str, const char *file, int line)
    254.   {
    255.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
                   ^
    256.           free_impl(str, file, line);
    257.           return;

crypto/mem.c:255:30: Taking true branch
    253.   void CRYPTO_free(void *str, const char *file, int line)
    254.   {
    255.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
                                        ^
    256.           free_impl(str, file, line);
    257.           return;

crypto/mem.c:256:9: Skipping __function_pointer__(): unresolved function pointer
    254.   {
    255.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
    256.           free_impl(str, file, line);
                   ^
    257.           return;
    258.       }

crypto/mem.c:257:9: 
    255.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
    256.           free_impl(str, file, line);
    257. >         return;
    258.       }
    259.   

crypto/mem.c:271:1: return from a call to CRYPTO_free
    269.       free(str);
    270.   #endif
    271. > }
    272.   
    273.   void CRYPTO_clear_free(void *str, size_t num, const char *file, int line)

crypto/x509/x509_vfy.c:2219:1: return from a call to X509_STORE_CTX_free
  2217.       X509_STORE_CTX_cleanup(ctx);
  2218.       OPENSSL_free(ctx);
  2219. > }
  2220.   
  2221.   int X509_STORE_CTX_init(X509_STORE_CTX *ctx, X509_STORE *store, X509 *x509,

int OCSP_request_verify(OCSP_REQUEST *req, STACK_OF(X509) *certs,
                        X509_STORE *store, unsigned long flags)
{
    X509 *signer;
    X509_NAME *nm;
    GENERAL_NAME *gen;
    int ret = 0;
    X509_STORE_CTX *ctx = X509_STORE_CTX_new();
    if (ctx == NULL) {
        OCSPerr(OCSP_F_OCSP_REQUEST_VERIFY, ERR_R_MALLOC_FAILURE);
        goto err;
    }
    if (!req->optionalSignature) {
        OCSPerr(OCSP_F_OCSP_REQUEST_VERIFY, OCSP_R_REQUEST_NOT_SIGNED);
        goto err;
    }
    gen = req->tbsRequest.requestorName;
    if (!gen || gen->type != GEN_DIRNAME) {
        OCSPerr(OCSP_F_OCSP_REQUEST_VERIFY,
                OCSP_R_UNSUPPORTED_REQUESTORNAME_TYPE);
        goto err;
    }
    nm = gen->d.directoryName;
    ret = ocsp_req_find_signer(&signer, req, nm, certs, flags);
    if (ret <= 0) {
        OCSPerr(OCSP_F_OCSP_REQUEST_VERIFY,
                OCSP_R_SIGNER_CERTIFICATE_NOT_FOUND);
        goto err;
    }
    if ((ret == 2) && (flags & OCSP_TRUSTOTHER))
        flags |= OCSP_NOVERIFY;
    if (!(flags & OCSP_NOSIGS)) {
        EVP_PKEY *skey;
        skey = X509_get0_pubkey(signer);
        ret = OCSP_REQUEST_verify(req, skey);
        if (ret <= 0) {
            OCSPerr(OCSP_F_OCSP_REQUEST_VERIFY, OCSP_R_SIGNATURE_FAILURE);
            goto err;
        }
    }
    if (!(flags & OCSP_NOVERIFY)) {
        int init_res;
        if (flags & OCSP_NOCHAIN)
            init_res = X509_STORE_CTX_init(ctx, store, signer, NULL);
        else
            init_res = X509_STORE_CTX_init(ctx, store, signer,
                                           req->optionalSignature->certs);
        if (!init_res) {
            OCSPerr(OCSP_F_OCSP_REQUEST_VERIFY, ERR_R_X509_LIB);
            goto err;
        }
        X509_STORE_CTX_set_purpose(ctx, X509_PURPOSE_OCSP_HELPER);
        X509_STORE_CTX_set_trust(ctx, X509_TRUST_OCSP_REQUEST);
        ret = X509_verify_cert(ctx);
        if (ret <= 0) {
            ret = X509_STORE_CTX_get_error(ctx);
            OCSPerr(OCSP_F_OCSP_REQUEST_VERIFY,
                    OCSP_R_CERTIFICATE_VERIFY_ERROR);
            ERR_add_error_data(2, "Verify error:",
                               X509_verify_cert_error_string(ret));
            goto err;
        }
    }
    ret = 1;
    goto end;
err:
    ret = 0;
end:
    X509_STORE_CTX_free(ctx);
    return ret;
}
['int OCSP_request_verify(OCSP_REQUEST *req, STACK_OF(X509) *certs,\n                        X509_STORE *store, unsigned long flags)\n{\n    X509 *signer;\n    X509_NAME *nm;\n    GENERAL_NAME *gen;\n    int ret = 0;\n    X509_STORE_CTX *ctx = X509_STORE_CTX_new();\n    if (ctx == NULL) {\n        OCSPerr(OCSP_F_OCSP_REQUEST_VERIFY, ERR_R_MALLOC_FAILURE);\n        goto err;\n    }\n    if (!req->optionalSignature) {\n        OCSPerr(OCSP_F_OCSP_REQUEST_VERIFY, OCSP_R_REQUEST_NOT_SIGNED);\n        goto err;\n    }\n    gen = req->tbsRequest.requestorName;\n    if (!gen || gen->type != GEN_DIRNAME) {\n        OCSPerr(OCSP_F_OCSP_REQUEST_VERIFY,\n                OCSP_R_UNSUPPORTED_REQUESTORNAME_TYPE);\n        goto err;\n    }\n    nm = gen->d.directoryName;\n    ret = ocsp_req_find_signer(&signer, req, nm, certs, flags);\n    if (ret <= 0) {\n        OCSPerr(OCSP_F_OCSP_REQUEST_VERIFY,\n                OCSP_R_SIGNER_CERTIFICATE_NOT_FOUND);\n        goto err;\n    }\n    if ((ret == 2) && (flags & OCSP_TRUSTOTHER))\n        flags |= OCSP_NOVERIFY;\n    if (!(flags & OCSP_NOSIGS)) {\n        EVP_PKEY *skey;\n        skey = X509_get0_pubkey(signer);\n        ret = OCSP_REQUEST_verify(req, skey);\n        if (ret <= 0) {\n            OCSPerr(OCSP_F_OCSP_REQUEST_VERIFY, OCSP_R_SIGNATURE_FAILURE);\n            goto err;\n        }\n    }\n    if (!(flags & OCSP_NOVERIFY)) {\n        int init_res;\n        if (flags & OCSP_NOCHAIN)\n            init_res = X509_STORE_CTX_init(ctx, store, signer, NULL);\n        else\n            init_res = X509_STORE_CTX_init(ctx, store, signer,\n                                           req->optionalSignature->certs);\n        if (!init_res) {\n            OCSPerr(OCSP_F_OCSP_REQUEST_VERIFY, ERR_R_X509_LIB);\n            goto err;\n        }\n        X509_STORE_CTX_set_purpose(ctx, X509_PURPOSE_OCSP_HELPER);\n        X509_STORE_CTX_set_trust(ctx, X509_TRUST_OCSP_REQUEST);\n        ret = X509_verify_cert(ctx);\n        if (ret <= 0) {\n            ret = X509_STORE_CTX_get_error(ctx);\n            OCSPerr(OCSP_F_OCSP_REQUEST_VERIFY,\n                    OCSP_R_CERTIFICATE_VERIFY_ERROR);\n            ERR_add_error_data(2, "Verify error:",\n                               X509_verify_cert_error_string(ret));\n            goto err;\n        }\n    }\n    ret = 1;\n    goto end;\nerr:\n    ret = 0;\nend:\n    X509_STORE_CTX_free(ctx);\n    return ret;\n}', 'X509_STORE_CTX *X509_STORE_CTX_new(void)\n{\n    X509_STORE_CTX *ctx = OPENSSL_zalloc(sizeof(*ctx));\n    if (ctx == NULL) {\n        X509err(X509_F_X509_STORE_CTX_NEW, ERR_R_MALLOC_FAILURE);\n        return NULL;\n    }\n    return ctx;\n}', 'void *CRYPTO_zalloc(size_t num, const char *file, int line)\n{\n    void *ret = CRYPTO_malloc(num, file, line);\n    FAILTEST();\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 (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)\n        return malloc_impl(num, file, line);\n    if (num == 0)\n        return NULL;\n    FAILTEST();\n    allow_customize = 0;\n#ifndef OPENSSL_NO_CRYPTO_MDEBUG\n    if (call_malloc_debug) {\n        CRYPTO_mem_debug_malloc(NULL, num, 0, file, line);\n        ret = malloc(num);\n        CRYPTO_mem_debug_malloc(ret, num, 1, file, line);\n    } else {\n        ret = malloc(num);\n    }\n#else\n    osslargused(file); osslargused(line);\n    ret = malloc(num);\n#endif\n    return ret;\n}', 'void X509_STORE_CTX_free(X509_STORE_CTX *ctx)\n{\n    if (ctx == NULL)\n        return;\n    X509_STORE_CTX_cleanup(ctx);\n    OPENSSL_free(ctx);\n}', 'void CRYPTO_free(void *str, const char *file, int line)\n{\n    if (free_impl != NULL && free_impl != &CRYPTO_free) {\n        free_impl(str, file, line);\n        return;\n    }\n#ifndef OPENSSL_NO_CRYPTO_MDEBUG\n    if (call_malloc_debug) {\n        CRYPTO_mem_debug_free(str, 0, file, line);\n        free(str);\n        CRYPTO_mem_debug_free(str, 1, file, line);\n    } else {\n        free(str);\n    }\n#else\n    free(str);\n#endif\n}']