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


crypto/ocsp/ocsp_vfy.c:339:1: start of procedure OCSP_request_verify()
337.    */
338.   
339. > int OCSP_request_verify(OCSP_REQUEST *req, STACK_OF(X509) *certs,
340.                           X509_STORE *store, unsigned long flags)
341.   {

crypto/ocsp/ocsp_vfy.c:345:5: 
343.       X509_NAME *nm;
344.       GENERAL_NAME *gen;
345. >     int ret = 0;
346.       X509_STORE_CTX *ctx = X509_STORE_CTX_new();
347.   

crypto/ocsp/ocsp_vfy.c:346:5: 
344.       GENERAL_NAME *gen;
345.       int ret = 0;
346. >     X509_STORE_CTX *ctx = X509_STORE_CTX_new();
347.   
348.       if (ctx == NULL) {

crypto/x509/x509_vfy.c:2179:1: start of procedure X509_STORE_CTX_new()
  2177.   }
  2178.   
  2179. > X509_STORE_CTX *X509_STORE_CTX_new(void)
  2180.   {
  2181.       X509_STORE_CTX *ctx = OPENSSL_zalloc(sizeof(*ctx));

crypto/x509/x509_vfy.c:2181:5: 
  2179.   X509_STORE_CTX *X509_STORE_CTX_new(void)
  2180.   {
  2181. >     X509_STORE_CTX *ctx = OPENSSL_zalloc(sizeof(*ctx));
  2182.   
  2183.       if (ctx == NULL) {

crypto/mem.c:228:1: start of procedure CRYPTO_zalloc()
    226.   }
    227.   
    228. > void *CRYPTO_zalloc(size_t num, const char *file, int line)
    229.   {
    230.       void *ret = CRYPTO_malloc(num, file, line);

crypto/mem.c:230:5: 
    228.   void *CRYPTO_zalloc(size_t num, const char *file, int line)
    229.   {
    230. >     void *ret = CRYPTO_malloc(num, file, line);
    231.   
    232.       FAILTEST();

crypto/mem.c:192:1: start of procedure CRYPTO_malloc()
      190.   #endif
      191.   
      192. > void *CRYPTO_malloc(size_t num, const char *file, int line)
      193.   {
      194.       void *ret = NULL;

crypto/mem.c:194:5: 
      192.   void *CRYPTO_malloc(size_t num, const char *file, int line)
      193.   {
      194. >     void *ret = NULL;
      195.   
      196.       INCREMENT(malloc_count);

crypto/mem.c:197:9: Taking false branch
      195.   
      196.       INCREMENT(malloc_count);
      197.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
                     ^
      198.           return malloc_impl(num, file, line);
      199.   

crypto/mem.c:200:9: Taking false branch
      198.           return malloc_impl(num, file, line);
      199.   
      200.       if (num == 0)
                     ^
      201.           return NULL;
      202.   

crypto/mem.c:204:9: Taking true branch
      202.   
      203.       FAILTEST();
      204.       if (allow_customize) {
                     ^
      205.           /*
      206.            * Disallow customization after the first allocation. We only set this

crypto/mem.c:210:9: 
      208.            * allocation.
      209.            */
      210. >         allow_customize = 0;
      211.       }
      212.   #if !defined(OPENSSL_NO_CRYPTO_MDEBUG) && !defined(FIPS_MODE)

crypto/mem.c:221:5: 
      219.       }
      220.   #else
      221. >     (void)(file); (void)(line);
      222.       ret = malloc(num);
      223.   #endif

crypto/mem.c:221:19: 
      219.       }
      220.   #else
      221. >     (void)(file); (void)(line);
      222.       ret = malloc(num);
      223.   #endif

crypto/mem.c:222:5: 
      220.   #else
      221.       (void)(file); (void)(line);
      222. >     ret = malloc(num);
      223.   #endif
      224.   

crypto/mem.c:225:5: 
      223.   #endif
      224.   
      225. >     return ret;
      226.   }
      227.   

crypto/mem.c:226:1: return from a call to CRYPTO_malloc
      224.   
      225.       return ret;
      226. > }
      227.   
      228.   void *CRYPTO_zalloc(size_t num, const char *file, int line)

crypto/mem.c:233:9: Taking true branch
    231.   
    232.       FAILTEST();
    233.       if (ret != NULL)
                   ^
    234.           memset(ret, 0, num);
    235.       return ret;

crypto/mem.c:234:9: 
    232.       FAILTEST();
    233.       if (ret != NULL)
    234. >         memset(ret, 0, num);
    235.       return ret;
    236.   }

crypto/mem.c:235:5: 
    233.       if (ret != NULL)
    234.           memset(ret, 0, num);
    235. >     return ret;
    236.   }
    237.   

crypto/mem.c:236:1: return from a call to CRYPTO_zalloc
    234.           memset(ret, 0, num);
    235.       return ret;
    236. > }
    237.   
    238.   void *CRYPTO_realloc(void *str, size_t num, const char *file, int line)

crypto/x509/x509_vfy.c:2183:9: Taking false branch
  2181.       X509_STORE_CTX *ctx = OPENSSL_zalloc(sizeof(*ctx));
  2182.   
  2183.       if (ctx == NULL) {
                  ^
  2184.           X509err(X509_F_X509_STORE_CTX_NEW, ERR_R_MALLOC_FAILURE);
  2185.           return NULL;

crypto/x509/x509_vfy.c:2187:5: 
  2185.           return NULL;
  2186.       }
  2187. >     return ctx;
  2188.   }
  2189.   

crypto/x509/x509_vfy.c:2188:1: return from a call to X509_STORE_CTX_new
  2186.       }
  2187.       return ctx;
  2188. > }
  2189.   
  2190.   void X509_STORE_CTX_free(X509_STORE_CTX *ctx)

crypto/ocsp/ocsp_vfy.c:348:9: Taking false branch
346.       X509_STORE_CTX *ctx = X509_STORE_CTX_new();
347.   
348.       if (ctx == NULL) {
               ^
349.           OCSPerr(OCSP_F_OCSP_REQUEST_VERIFY, ERR_R_MALLOC_FAILURE);
350.           goto err;

crypto/ocsp/ocsp_vfy.c:353:10: Taking true branch
351.       }
352.   
353.       if (!req->optionalSignature) {
                ^
354.           OCSPerr(OCSP_F_OCSP_REQUEST_VERIFY, OCSP_R_REQUEST_NOT_SIGNED);
355.           goto err;

crypto/ocsp/ocsp_vfy.c:354:9: Skipping ERR_put_error(): empty list of specs
352.   
353.       if (!req->optionalSignature) {
354.           OCSPerr(OCSP_F_OCSP_REQUEST_VERIFY, OCSP_R_REQUEST_NOT_SIGNED);
               ^
355.           goto err;
356.       }

crypto/ocsp/ocsp_vfy.c:408:1: 
406.       goto end;
407.   
408. > err:
409.       ret = 0;
410.   end:

crypto/ocsp/ocsp_vfy.c:409:5: 
407.   
408.   err:
409. >     ret = 0;
410.   end:
411.       X509_STORE_CTX_free(ctx);

crypto/ocsp/ocsp_vfy.c:410:1: 
408.   err:
409.       ret = 0;
410. > end:
411.       X509_STORE_CTX_free(ctx);
412.       return ret;

crypto/ocsp/ocsp_vfy.c:411:5: 
409.       ret = 0;
410.   end:
411. >     X509_STORE_CTX_free(ctx);
412.       return ret;
413.   

crypto/x509/x509_vfy.c:2190:1: start of procedure X509_STORE_CTX_free()
  2188.   }
  2189.   
  2190. > void X509_STORE_CTX_free(X509_STORE_CTX *ctx)
  2191.   {
  2192.       if (ctx == NULL)

crypto/x509/x509_vfy.c:2192:9: Taking false branch
  2190.   void X509_STORE_CTX_free(X509_STORE_CTX *ctx)
  2191.   {
  2192.       if (ctx == NULL)
                  ^
  2193.           return;
  2194.   

crypto/x509/x509_vfy.c:2195:5: Skipping X509_STORE_CTX_cleanup(): empty list of specs
  2193.           return;
  2194.   
  2195.       X509_STORE_CTX_cleanup(ctx);
              ^
  2196.       OPENSSL_free(ctx);
  2197.   }

crypto/x509/x509_vfy.c:2196:5: 
  2194.   
  2195.       X509_STORE_CTX_cleanup(ctx);
  2196. >     OPENSSL_free(ctx);
  2197.   }
  2198.   

crypto/mem.c:295:1: start of procedure CRYPTO_free()
    293.   }
    294.   
    295. > void CRYPTO_free(void *str, const char *file, int line)
    296.   {
    297.       INCREMENT(free_count);

crypto/mem.c:298:9: Taking true branch
    296.   {
    297.       INCREMENT(free_count);
    298.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
                   ^
    299.           free_impl(str, file, line);
    300.           return;

crypto/mem.c:298:30: Taking true branch
    296.   {
    297.       INCREMENT(free_count);
    298.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
                                        ^
    299.           free_impl(str, file, line);
    300.           return;

crypto/mem.c:299:9: Skipping __function_pointer__(): unresolved function pointer
    297.       INCREMENT(free_count);
    298.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
    299.           free_impl(str, file, line);
                   ^
    300.           return;
    301.       }

crypto/mem.c:300:9: 
    298.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
    299.           free_impl(str, file, line);
    300. >         return;
    301.       }
    302.   

crypto/mem.c:314:1: return from a call to CRYPTO_free
    312.       free(str);
    313.   #endif
    314. > }
    315.   
    316.   void CRYPTO_clear_free(void *str, size_t num, const char *file, int line)

crypto/x509/x509_vfy.c:2197:1: return from a call to X509_STORE_CTX_free
  2195.       X509_STORE_CTX_cleanup(ctx);
  2196.       OPENSSL_free(ctx);
  2197. > }
  2198.   
  2199.   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    INCREMENT(malloc_count);\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    if (allow_customize) {\n        allow_customize = 0;\n    }\n#if !defined(OPENSSL_NO_CRYPTO_MDEBUG) && !defined(FIPS_MODE)\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    (void)(file); (void)(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    INCREMENT(free_count);\n    if (free_impl != NULL && free_impl != &CRYPTO_free) {\n        free_impl(str, file, line);\n        return;\n    }\n#if !defined(OPENSSL_NO_CRYPTO_MDEBUG) && !defined(FIPS_MODE)\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}']