crypto/provider_core.c:186: error: MEMORY_LEAK
  memory dynamically allocated by call to `CRYPTO_zalloc()` at line 180, column 17 is not reachable after line 186, column 9.
Showing all 48 steps of the trace


crypto/provider_core.c:175:1: start of procedure provider_new()
173.    */
174.   
175. > static OSSL_PROVIDER *provider_new(const char *name,
176.                                      OSSL_provider_init_fn *init_function)
177.   {

crypto/provider_core.c:178:5: 
176.                                      OSSL_provider_init_fn *init_function)
177.   {
178. >     OSSL_PROVIDER *prov = NULL;
179.   
180.       if ((prov = OPENSSL_zalloc(sizeof(*prov))) == NULL

crypto/provider_core.c:180:9: 
178.       OSSL_PROVIDER *prov = NULL;
179.   
180. >     if ((prov = OPENSSL_zalloc(sizeof(*prov))) == NULL
181.   #ifndef HAVE_ATOMICS
182.           || (prov->refcnt_lock = CRYPTO_THREAD_lock_new()) == 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/provider_core.c:180:9: Taking false branch
178.       OSSL_PROVIDER *prov = NULL;
179.   
180.       if ((prov = OPENSSL_zalloc(sizeof(*prov))) == NULL
               ^
181.   #ifndef HAVE_ATOMICS
182.           || (prov->refcnt_lock = CRYPTO_THREAD_lock_new()) == NULL

crypto/provider_core.c:184:13: 
182.           || (prov->refcnt_lock = CRYPTO_THREAD_lock_new()) == NULL
183.   #endif
184. >         || !ossl_provider_upref(prov) /* +1 One reference to be returned */
185.           || (prov->name = OPENSSL_strdup(name)) == NULL) {
186.           ossl_provider_free(prov);

crypto/provider_core.c:195:1: start of procedure ossl_provider_upref()
  193.   }
  194.   
  195. > int ossl_provider_upref(OSSL_PROVIDER *prov)
  196.   {
  197.       int ref = 0;

crypto/provider_core.c:197:5: 
  195.   int ossl_provider_upref(OSSL_PROVIDER *prov)
  196.   {
  197. >     int ref = 0;
  198.   
  199.       if (CRYPTO_UP_REF(&prov->refcnt, &ref, prov->refcnt_lock) <= 0)

crypto/provider_core.c:199:9: 
  197.       int ref = 0;
  198.   
  199. >     if (CRYPTO_UP_REF(&prov->refcnt, &ref, prov->refcnt_lock) <= 0)
  200.           return 0;
  201.       return ref;

include/internal/refcount.h:33:1: start of procedure CRYPTO_UP_REF()
    31.   typedef _Atomic int CRYPTO_REF_COUNT;
    32.   
    33. > static inline int CRYPTO_UP_REF(_Atomic int *val, int *ret, void *lock)
    34.   {
    35.       *ret = atomic_fetch_add_explicit(val, 1, memory_order_relaxed) + 1;

include/internal/refcount.h:35:5: 
    33.   static inline int CRYPTO_UP_REF(_Atomic int *val, int *ret, void *lock)
    34.   {
    35. >     *ret = atomic_fetch_add_explicit(val, 1, memory_order_relaxed) + 1;
    36.       return 1;
    37.   }

include/internal/refcount.h:36:5: 
    34.   {
    35.       *ret = atomic_fetch_add_explicit(val, 1, memory_order_relaxed) + 1;
    36. >     return 1;
    37.   }
    38.   

include/internal/refcount.h:37:1: return from a call to CRYPTO_UP_REF
    35.       *ret = atomic_fetch_add_explicit(val, 1, memory_order_relaxed) + 1;
    36.       return 1;
    37. > }
    38.   
    39.   /*

crypto/provider_core.c:199:9: Taking false branch
  197.       int ref = 0;
  198.   
  199.       if (CRYPTO_UP_REF(&prov->refcnt, &ref, prov->refcnt_lock) <= 0)
                 ^
  200.           return 0;
  201.       return ref;

crypto/provider_core.c:201:5: 
  199.       if (CRYPTO_UP_REF(&prov->refcnt, &ref, prov->refcnt_lock) <= 0)
  200.           return 0;
  201. >     return ref;
  202.   }
  203.   

crypto/provider_core.c:202:1: return from a call to ossl_provider_upref
  200.           return 0;
  201.       return ref;
  202. > }
  203.   
  204.   OSSL_PROVIDER *ossl_provider_new(OPENSSL_CTX *libctx, const char *name,

crypto/provider_core.c:184:13: Taking false branch
182.           || (prov->refcnt_lock = CRYPTO_THREAD_lock_new()) == NULL
183.   #endif
184.           || !ossl_provider_upref(prov) /* +1 One reference to be returned */
                   ^
185.           || (prov->name = OPENSSL_strdup(name)) == NULL) {
186.           ossl_provider_free(prov);

crypto/provider_core.c:185:12: 
183.   #endif
184.           || !ossl_provider_upref(prov) /* +1 One reference to be returned */
185. >         || (prov->name = OPENSSL_strdup(name)) == NULL) {
186.           ossl_provider_free(prov);
187.           CRYPTOerr(CRYPTO_F_PROVIDER_NEW, ERR_R_MALLOC_FAILURE);

crypto/o_str.c:15:1: start of procedure CRYPTO_strdup()
  13.   #include "internal/cryptlib.h"
  14.   
  15. > char *CRYPTO_strdup(const char *str, const char* file, int line)
  16.   {
  17.       char *ret;

crypto/o_str.c:19:9: Taking false branch
  17.       char *ret;
  18.   
  19.       if (str == NULL)
                ^
  20.           return NULL;
  21.       ret = CRYPTO_malloc(strlen(str) + 1, file, line);

crypto/o_str.c:21:5: 
  19.       if (str == NULL)
  20.           return NULL;
  21. >     ret = CRYPTO_malloc(strlen(str) + 1, file, line);
  22.       if (ret != NULL)
  23.           strcpy(ret, str);

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 true 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:197:32: Taking true 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:198:9: Skipping __function_pointer__(): unresolved function pointer
    196.       INCREMENT(malloc_count);
    197.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
    198.           return malloc_impl(num, file, line);
                   ^
    199.   
    200.       if (num == 0)

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/o_str.c:22:9: Taking false branch
  20.           return NULL;
  21.       ret = CRYPTO_malloc(strlen(str) + 1, file, line);
  22.       if (ret != NULL)
                ^
  23.           strcpy(ret, str);
  24.       return ret;

crypto/o_str.c:24:5: 
  22.       if (ret != NULL)
  23.           strcpy(ret, str);
  24. >     return ret;
  25.   }
  26.   

crypto/o_str.c:25:1: return from a call to CRYPTO_strdup
  23.           strcpy(ret, str);
  24.       return ret;
  25. > }
  26.   
  27.   char *CRYPTO_strndup(const char *str, size_t s, const char* file, int line)

crypto/provider_core.c:185:12: Taking true branch
183.   #endif
184.           || !ossl_provider_upref(prov) /* +1 One reference to be returned */
185.           || (prov->name = OPENSSL_strdup(name)) == NULL) {
                  ^
186.           ossl_provider_free(prov);
187.           CRYPTOerr(CRYPTO_F_PROVIDER_NEW, ERR_R_MALLOC_FAILURE);

crypto/provider_core.c:186:9: Skipping ossl_provider_free(): empty list of specs
184.           || !ossl_provider_upref(prov) /* +1 One reference to be returned */
185.           || (prov->name = OPENSSL_strdup(name)) == NULL) {
186.           ossl_provider_free(prov);
               ^
187.           CRYPTOerr(CRYPTO_F_PROVIDER_NEW, ERR_R_MALLOC_FAILURE);
188.           return NULL;

static OSSL_PROVIDER *provider_new(const char *name,
                                   OSSL_provider_init_fn *init_function)
{
    OSSL_PROVIDER *prov = NULL;
    if ((prov = OPENSSL_zalloc(sizeof(*prov))) == NULL
#ifndef HAVE_ATOMICS
        || (prov->refcnt_lock = CRYPTO_THREAD_lock_new()) == NULL
#endif
        || !ossl_provider_upref(prov)
        || (prov->name = OPENSSL_strdup(name)) == NULL) {
        ossl_provider_free(prov);
        CRYPTOerr(CRYPTO_F_PROVIDER_NEW, ERR_R_MALLOC_FAILURE);
        return NULL;
    }
    prov->init_function = init_function;
    return prov;
}
['static OSSL_PROVIDER *provider_new(const char *name,\n                                   OSSL_provider_init_fn *init_function)\n{\n    OSSL_PROVIDER *prov = NULL;\n    if ((prov = OPENSSL_zalloc(sizeof(*prov))) == NULL\n#ifndef HAVE_ATOMICS\n        || (prov->refcnt_lock = CRYPTO_THREAD_lock_new()) == NULL\n#endif\n        || !ossl_provider_upref(prov)\n        || (prov->name = OPENSSL_strdup(name)) == NULL) {\n        ossl_provider_free(prov);\n        CRYPTOerr(CRYPTO_F_PROVIDER_NEW, ERR_R_MALLOC_FAILURE);\n        return NULL;\n    }\n    prov->init_function = init_function;\n    return prov;\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}', 'int ossl_provider_upref(OSSL_PROVIDER *prov)\n{\n    int ref = 0;\n    if (CRYPTO_UP_REF(&prov->refcnt, &ref, prov->refcnt_lock) <= 0)\n        return 0;\n    return ref;\n}', 'static inline int CRYPTO_UP_REF(_Atomic int *val, int *ret, void *lock)\n{\n    *ret = atomic_fetch_add_explicit(val, 1, memory_order_relaxed) + 1;\n    return 1;\n}', 'char *CRYPTO_strdup(const char *str, const char* file, int line)\n{\n    char *ret;\n    if (str == NULL)\n        return NULL;\n    ret = CRYPTO_malloc(strlen(str) + 1, file, line);\n    if (ret != NULL)\n        strcpy(ret, str);\n    return ret;\n}']