crypto/dsa/dsa_lib.c:108: error: MEMORY_LEAK
  memory dynamically allocated by call to `CRYPTO_zalloc()` at line 66, column 16 is not reachable after line 108, column 9.
Showing all 96 steps of the trace


crypto/dsa/dsa_lib.c:64:1: start of procedure DSA_new_method()
62.   }
63.   
64. > DSA *DSA_new_method(ENGINE *engine)
65.   {
66.       DSA *ret = OPENSSL_zalloc(sizeof(*ret));

crypto/dsa/dsa_lib.c:66:5: 
64.   DSA *DSA_new_method(ENGINE *engine)
65.   {
66. >     DSA *ret = OPENSSL_zalloc(sizeof(*ret));
67.   
68.       if (ret == NULL) {

crypto/mem.c:98:1: start of procedure CRYPTO_zalloc()
  96.   }
  97.   
  98. > void *CRYPTO_zalloc(size_t num, const char *file, int line)
  99.   {
  100.       void *ret = CRYPTO_malloc(num, file, line);

crypto/mem.c:100:5: 
  98.   void *CRYPTO_zalloc(size_t num, const char *file, int line)
  99.   {
  100. >     void *ret = CRYPTO_malloc(num, file, line);
  101.   
  102.       if (ret != NULL)

crypto/mem.c:71:1: start of procedure CRYPTO_malloc()
    69.   }
    70.   
    71. > void *CRYPTO_malloc(size_t num, const char *file, int line)
    72.   {
    73.       void *ret = NULL;

crypto/mem.c:73:5: 
    71.   void *CRYPTO_malloc(size_t num, const char *file, int line)
    72.   {
    73. >     void *ret = NULL;
    74.   
    75.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)

crypto/mem.c:75:9: Taking false branch
    73.       void *ret = NULL;
    74.   
    75.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
                  ^
    76.           return malloc_impl(num, file, line);
    77.   

crypto/mem.c:78:9: Taking false branch
    76.           return malloc_impl(num, file, line);
    77.   
    78.       if (num <= 0)
                  ^
    79.           return NULL;
    80.   

crypto/mem.c:81:5: 
    79.           return NULL;
    80.   
    81. >     allow_customize = 0;
    82.   #ifndef OPENSSL_NO_CRYPTO_MDEBUG
    83.       if (call_malloc_debug) {

crypto/mem.c:91:5: 
    89.       }
    90.   #else
    91. >     osslargused(file); osslargused(line);
    92.       ret = malloc(num);
    93.   #endif

crypto/mem.c:91:24: 
    89.       }
    90.   #else
    91. >     osslargused(file); osslargused(line);
    92.       ret = malloc(num);
    93.   #endif

crypto/mem.c:92:5: 
    90.   #else
    91.       osslargused(file); osslargused(line);
    92. >     ret = malloc(num);
    93.   #endif
    94.   

crypto/mem.c:95:5: 
    93.   #endif
    94.   
    95. >     return ret;
    96.   }
    97.   

crypto/mem.c:96:1: return from a call to CRYPTO_malloc
    94.   
    95.       return ret;
    96. > }
    97.   
    98.   void *CRYPTO_zalloc(size_t num, const char *file, int line)

crypto/mem.c:102:9: Taking true branch
  100.       void *ret = CRYPTO_malloc(num, file, line);
  101.   
  102.       if (ret != NULL)
                 ^
  103.           memset(ret, 0, num);
  104.       return ret;

crypto/mem.c:103:9: 
  101.   
  102.       if (ret != NULL)
  103. >         memset(ret, 0, num);
  104.       return ret;
  105.   }

crypto/mem.c:104:5: 
  102.       if (ret != NULL)
  103.           memset(ret, 0, num);
  104. >     return ret;
  105.   }
  106.   

crypto/mem.c:105:1: return from a call to CRYPTO_zalloc
  103.           memset(ret, 0, num);
  104.       return ret;
  105. > }
  106.   
  107.   void *CRYPTO_realloc(void *str, size_t num, const char *file, int line)

crypto/dsa/dsa_lib.c:68:9: Taking false branch
66.       DSA *ret = OPENSSL_zalloc(sizeof(*ret));
67.   
68.       if (ret == NULL) {
              ^
69.           DSAerr(DSA_F_DSA_NEW_METHOD, ERR_R_MALLOC_FAILURE);
70.           return NULL;

crypto/dsa/dsa_lib.c:73:5: 
71.       }
72.   
73. >     ret->references = 1;
74.       ret->lock = CRYPTO_THREAD_lock_new();
75.       if (ret->lock == NULL) {

crypto/dsa/dsa_lib.c:74:5: 
72.   
73.       ret->references = 1;
74. >     ret->lock = CRYPTO_THREAD_lock_new();
75.       if (ret->lock == NULL) {
76.           OPENSSL_free(ret);

crypto/threads_pthread.c:14:1: start of procedure CRYPTO_THREAD_lock_new()
  12.   #if defined(OPENSSL_THREADS) && !defined(CRYPTO_TDEBUG) && !defined(OPENSSL_SYS_WINDOWS)
  13.   
  14. > CRYPTO_RWLOCK *CRYPTO_THREAD_lock_new(void)
  15.   {
  16.       CRYPTO_RWLOCK *lock = OPENSSL_zalloc(sizeof(pthread_rwlock_t));

crypto/threads_pthread.c:16:5: 
  14.   CRYPTO_RWLOCK *CRYPTO_THREAD_lock_new(void)
  15.   {
  16. >     CRYPTO_RWLOCK *lock = OPENSSL_zalloc(sizeof(pthread_rwlock_t));
  17.       if (lock == NULL)
  18.           return NULL;

crypto/mem.c:98:1: start of procedure CRYPTO_zalloc()
    96.   }
    97.   
    98. > void *CRYPTO_zalloc(size_t num, const char *file, int line)
    99.   {
    100.       void *ret = CRYPTO_malloc(num, file, line);

crypto/mem.c:100:5: 
    98.   void *CRYPTO_zalloc(size_t num, const char *file, int line)
    99.   {
    100. >     void *ret = CRYPTO_malloc(num, file, line);
    101.   
    102.       if (ret != NULL)

crypto/mem.c:71:1: start of procedure CRYPTO_malloc()
      69.   }
      70.   
      71. > void *CRYPTO_malloc(size_t num, const char *file, int line)
      72.   {
      73.       void *ret = NULL;

crypto/mem.c:73:5: 
      71.   void *CRYPTO_malloc(size_t num, const char *file, int line)
      72.   {
      73. >     void *ret = NULL;
      74.   
      75.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)

crypto/mem.c:75:9: Taking false branch
      73.       void *ret = NULL;
      74.   
      75.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
                    ^
      76.           return malloc_impl(num, file, line);
      77.   

crypto/mem.c:78:9: Taking false branch
      76.           return malloc_impl(num, file, line);
      77.   
      78.       if (num <= 0)
                    ^
      79.           return NULL;
      80.   

crypto/mem.c:81:5: 
      79.           return NULL;
      80.   
      81. >     allow_customize = 0;
      82.   #ifndef OPENSSL_NO_CRYPTO_MDEBUG
      83.       if (call_malloc_debug) {

crypto/mem.c:91:5: 
      89.       }
      90.   #else
      91. >     osslargused(file); osslargused(line);
      92.       ret = malloc(num);
      93.   #endif

crypto/mem.c:91:24: 
      89.       }
      90.   #else
      91. >     osslargused(file); osslargused(line);
      92.       ret = malloc(num);
      93.   #endif

crypto/mem.c:92:5: 
      90.   #else
      91.       osslargused(file); osslargused(line);
      92. >     ret = malloc(num);
      93.   #endif
      94.   

crypto/mem.c:95:5: 
      93.   #endif
      94.   
      95. >     return ret;
      96.   }
      97.   

crypto/mem.c:96:1: return from a call to CRYPTO_malloc
      94.   
      95.       return ret;
      96. > }
      97.   
      98.   void *CRYPTO_zalloc(size_t num, const char *file, int line)

crypto/mem.c:102:9: Taking true branch
    100.       void *ret = CRYPTO_malloc(num, file, line);
    101.   
    102.       if (ret != NULL)
                   ^
    103.           memset(ret, 0, num);
    104.       return ret;

crypto/mem.c:103:9: 
    101.   
    102.       if (ret != NULL)
    103. >         memset(ret, 0, num);
    104.       return ret;
    105.   }

crypto/mem.c:104:5: 
    102.       if (ret != NULL)
    103.           memset(ret, 0, num);
    104. >     return ret;
    105.   }
    106.   

crypto/mem.c:105:1: return from a call to CRYPTO_zalloc
    103.           memset(ret, 0, num);
    104.       return ret;
    105. > }
    106.   
    107.   void *CRYPTO_realloc(void *str, size_t num, const char *file, int line)

crypto/threads_pthread.c:17:9: Taking false branch
  15.   {
  16.       CRYPTO_RWLOCK *lock = OPENSSL_zalloc(sizeof(pthread_rwlock_t));
  17.       if (lock == NULL)
                ^
  18.           return NULL;
  19.   

crypto/threads_pthread.c:20:9: Taking false branch
  18.           return NULL;
  19.   
  20.       if (pthread_rwlock_init(lock, NULL) != 0) {
                ^
  21.           OPENSSL_free(lock);
  22.           return NULL;

crypto/threads_pthread.c:25:5: 
  23.       }
  24.   
  25. >     return lock;
  26.   }
  27.   

crypto/threads_pthread.c:26:1: return from a call to CRYPTO_THREAD_lock_new
  24.   
  25.       return lock;
  26. > }
  27.   
  28.   int CRYPTO_THREAD_read_lock(CRYPTO_RWLOCK *lock)

crypto/dsa/dsa_lib.c:75:9: Taking false branch
73.       ret->references = 1;
74.       ret->lock = CRYPTO_THREAD_lock_new();
75.       if (ret->lock == NULL) {
              ^
76.           OPENSSL_free(ret);
77.           return NULL;

crypto/dsa/dsa_lib.c:80:5: 
78.       }
79.   
80. >     ret->meth = DSA_get_default_method();
81.   #ifndef OPENSSL_NO_ENGINE
82.       ret->flags = ret->meth->flags & ~DSA_FLAG_NON_FIPS_ALLOW; /* early default init */

crypto/dsa/dsa_lib.c:27:1: start of procedure DSA_get_default_method()
  25.   }
  26.   
  27. > const DSA_METHOD *DSA_get_default_method(void)
  28.   {
  29.       if (!default_DSA_method)

crypto/dsa/dsa_lib.c:29:10: Taking false branch
  27.   const DSA_METHOD *DSA_get_default_method(void)
  28.   {
  29.       if (!default_DSA_method)
                 ^
  30.           default_DSA_method = DSA_OpenSSL();
  31.       return default_DSA_method;

crypto/dsa/dsa_lib.c:31:5: 
  29.       if (!default_DSA_method)
  30.           default_DSA_method = DSA_OpenSSL();
  31. >     return default_DSA_method;
  32.   }
  33.   

crypto/dsa/dsa_lib.c:32:1: return from a call to DSA_get_default_method
  30.           default_DSA_method = DSA_OpenSSL();
  31.       return default_DSA_method;
  32. > }
  33.   
  34.   DSA *DSA_new(void)

crypto/dsa/dsa_lib.c:82:5: 
80.       ret->meth = DSA_get_default_method();
81.   #ifndef OPENSSL_NO_ENGINE
82. >     ret->flags = ret->meth->flags & ~DSA_FLAG_NON_FIPS_ALLOW; /* early default init */
83.       if (engine) {
84.           if (!ENGINE_init(engine)) {

crypto/dsa/dsa_lib.c:83:9: Taking false branch
81.   #ifndef OPENSSL_NO_ENGINE
82.       ret->flags = ret->meth->flags & ~DSA_FLAG_NON_FIPS_ALLOW; /* early default init */
83.       if (engine) {
              ^
84.           if (!ENGINE_init(engine)) {
85.               DSAerr(DSA_F_DSA_NEW_METHOD, ERR_R_ENGINE_LIB);

crypto/dsa/dsa_lib.c:90:9: 
88.           ret->engine = engine;
89.       } else
90. >         ret->engine = ENGINE_get_default_DSA();
91.       if (ret->engine) {
92.           ret->meth = ENGINE_get_DSA(ret->engine);

crypto/engine/tb_dsa.c:56:1: start of procedure ENGINE_get_default_DSA()
  54.    * references).
  55.    */
  56. > ENGINE *ENGINE_get_default_DSA(void)
  57.   {
  58.       return engine_table_select(&dsa_table, dummy_nid);

crypto/engine/tb_dsa.c:58:5: 
  56.   ENGINE *ENGINE_get_default_DSA(void)
  57.   {
  58. >     return engine_table_select(&dsa_table, dummy_nid);
  59.   }
  60.   

crypto/engine/eng_table.c:188:1: start of procedure engine_table_select()
    186.   /* return a functional reference for a given 'nid' */
    187.   #ifndef ENGINE_TABLE_DEBUG
    188. > ENGINE *engine_table_select(ENGINE_TABLE **table, int nid)
    189.   #else
    190.   ENGINE *engine_table_select_tmp(ENGINE_TABLE **table, int nid, const char *f,

crypto/engine/eng_table.c:194:5: 
    192.   #endif
    193.   {
    194. >     ENGINE *ret = NULL;
    195.       ENGINE_PILE tmplate, *fnd = NULL;
    196.       int initres, loop = 0;

crypto/engine/eng_table.c:195:5: 
    193.   {
    194.       ENGINE *ret = NULL;
    195. >     ENGINE_PILE tmplate, *fnd = NULL;
    196.       int initres, loop = 0;
    197.   

crypto/engine/eng_table.c:196:5: 
    194.       ENGINE *ret = NULL;
    195.       ENGINE_PILE tmplate, *fnd = NULL;
    196. >     int initres, loop = 0;
    197.   
    198.       if (!(*table)) {

crypto/engine/eng_table.c:198:11: 
    196.       int initres, loop = 0;
    197.   
    198. >     if (!(*table)) {
    199.   #ifdef ENGINE_TABLE_DEBUG
    200.           fprintf(stderr, "engine_table_dbg: %s:%d, nid=%d, nothing "

crypto/engine/eng_table.c:198:10: Taking true branch
    196.       int initres, loop = 0;
    197.   
    198.       if (!(*table)) {
                    ^
    199.   #ifdef ENGINE_TABLE_DEBUG
    200.           fprintf(stderr, "engine_table_dbg: %s:%d, nid=%d, nothing "

crypto/engine/eng_table.c:203:9: 
    201.                   "registered!\n", f, l, nid);
    202.   #endif
    203. >         return NULL;
    204.       }
    205.       ERR_set_mark();

crypto/engine/eng_table.c:284:1: return from a call to engine_table_select
    282.       ERR_pop_to_mark();
    283.       return ret;
    284. > }
    285.   
    286.   /* Table enumeration */

crypto/engine/tb_dsa.c:59:1: return from a call to ENGINE_get_default_DSA
  57.   {
  58.       return engine_table_select(&dsa_table, dummy_nid);
  59. > }
  60.   
  61.   /* Obtains an DSA implementation from an ENGINE functional reference */

crypto/dsa/dsa_lib.c:91:9: Taking false branch
89.       } else
90.           ret->engine = ENGINE_get_default_DSA();
91.       if (ret->engine) {
              ^
92.           ret->meth = ENGINE_get_DSA(ret->engine);
93.           if (ret->meth == NULL) {

crypto/dsa/dsa_lib.c:100:5: 
98.   #endif
99.   
100. >     ret->flags = ret->meth->flags & ~DSA_FLAG_NON_FIPS_ALLOW;
101.   
102.       if (!CRYPTO_new_ex_data(CRYPTO_EX_INDEX_DSA, ret, &ret->ex_data))

crypto/dsa/dsa_lib.c:102:10: 
100.       ret->flags = ret->meth->flags & ~DSA_FLAG_NON_FIPS_ALLOW;
101.   
102. >     if (!CRYPTO_new_ex_data(CRYPTO_EX_INDEX_DSA, ret, &ret->ex_data))
103.           goto err;
104.   

crypto/ex_data.c:202:1: start of procedure CRYPTO_new_ex_data()
  200.    * to the global "ex_data" state (ie. class definitions), not 'ad' itself.
  201.    */
  202. > int CRYPTO_new_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad)
  203.   {
  204.       int mx, i;

crypto/ex_data.c:206:5: 
  204.       int mx, i;
  205.       void *ptr;
  206. >     EX_CALLBACK **storage = NULL;
  207.       EX_CALLBACK *stack[10];
  208.       EX_CALLBACKS *ip = get_and_lock(class_index);

crypto/ex_data.c:208:5: 
  206.       EX_CALLBACK **storage = NULL;
  207.       EX_CALLBACK *stack[10];
  208. >     EX_CALLBACKS *ip = get_and_lock(class_index);
  209.   
  210.       if (ip == NULL)

crypto/ex_data.c:47:1: start of procedure get_and_lock()
    45.    * a given class.  On success, *holds the lock.*
    46.    */
    47. > static EX_CALLBACKS *get_and_lock(int class_index)
    48.   {
    49.       EX_CALLBACKS *ip;

crypto/ex_data.c:51:9: Taking false branch
    49.       EX_CALLBACKS *ip;
    50.   
    51.       if (class_index < 0 || class_index >= CRYPTO_EX_INDEX__COUNT) {
                  ^
    52.           CRYPTOerr(CRYPTO_F_GET_AND_LOCK, ERR_R_PASSED_INVALID_ARGUMENT);
    53.           return NULL;

crypto/ex_data.c:51:28: Taking false branch
    49.       EX_CALLBACKS *ip;
    50.   
    51.       if (class_index < 0 || class_index >= CRYPTO_EX_INDEX__COUNT) {
                                     ^
    52.           CRYPTOerr(CRYPTO_F_GET_AND_LOCK, ERR_R_PASSED_INVALID_ARGUMENT);
    53.           return NULL;

crypto/ex_data.c:56:5: 
    54.       }
    55.   
    56. >     CRYPTO_THREAD_run_once(&ex_data_init, do_ex_data_init);
    57.   
    58.       if (ex_data_lock == NULL) {

crypto/threads_pthread.c:63:1: start of procedure CRYPTO_THREAD_run_once()
      61.   }
      62.   
      63. > int CRYPTO_THREAD_run_once(CRYPTO_ONCE *once, void (*init)(void))
      64.   {
      65.       if (pthread_once(once, init) != 0)

crypto/threads_pthread.c:65:9: Taking true branch
      63.   int CRYPTO_THREAD_run_once(CRYPTO_ONCE *once, void (*init)(void))
      64.   {
      65.       if (pthread_once(once, init) != 0)
                    ^
      66.           return 0;
      67.   

crypto/threads_pthread.c:66:9: 
      64.   {
      65.       if (pthread_once(once, init) != 0)
      66. >         return 0;
      67.   
      68.       return 1;

crypto/threads_pthread.c:69:1: return from a call to CRYPTO_THREAD_run_once
      67.   
      68.       return 1;
      69. > }
      70.   
      71.   int CRYPTO_THREAD_init_local(CRYPTO_THREAD_LOCAL *key, void (*cleanup)(void *))

crypto/ex_data.c:58:9: Taking true branch
    56.       CRYPTO_THREAD_run_once(&ex_data_init, do_ex_data_init);
    57.   
    58.       if (ex_data_lock == NULL) {
                  ^
    59.           /*
    60.            * This can happen in normal operation when using CRYPTO_mem_leaks().

crypto/ex_data.c:68:10: 
    66.            * ignore this operation. We just treat it as an error.
    67.            */
    68. >          return NULL;
    69.       }
    70.   

crypto/ex_data.c:74:1: return from a call to get_and_lock
    72.       CRYPTO_THREAD_write_lock(ex_data_lock);
    73.       return ip;
    74. > }
    75.   
    76.   static void cleanup_cb(EX_CALLBACK *funcs)

crypto/ex_data.c:210:9: Taking true branch
  208.       EX_CALLBACKS *ip = get_and_lock(class_index);
  209.   
  210.       if (ip == NULL)
                 ^
  211.           return 0;
  212.   

crypto/ex_data.c:211:9: 
  209.   
  210.       if (ip == NULL)
  211. >         return 0;
  212.   
  213.       ad->sk = NULL;

crypto/ex_data.c:241:1: return from a call to CRYPTO_new_ex_data
  239.           OPENSSL_free(storage);
  240.       return 1;
  241. > }
  242.   
  243.   /*

crypto/dsa/dsa_lib.c:102:10: Taking true branch
100.       ret->flags = ret->meth->flags & ~DSA_FLAG_NON_FIPS_ALLOW;
101.   
102.       if (!CRYPTO_new_ex_data(CRYPTO_EX_INDEX_DSA, ret, &ret->ex_data))
                ^
103.           goto err;
104.   

crypto/dsa/dsa_lib.c:107:1: 
105.       if ((ret->meth->init != NULL) && !ret->meth->init(ret)) {
106.           DSAerr(DSA_F_DSA_NEW_METHOD, ERR_R_INIT_FAIL);
107. > err:
108.           DSA_free(ret);
109.           ret = NULL;

crypto/dsa/dsa_lib.c:108:9: 
106.           DSAerr(DSA_F_DSA_NEW_METHOD, ERR_R_INIT_FAIL);
107.   err:
108. >         DSA_free(ret);
109.           ret = NULL;
110.       }

crypto/dsa/dsa_lib.c:115:1: start of procedure DSA_free()
  113.   }
  114.   
  115. > void DSA_free(DSA *r)
  116.   {
  117.       int i;

crypto/dsa/dsa_lib.c:119:9: Taking false branch
  117.       int i;
  118.   
  119.       if (r == NULL)
                 ^
  120.           return;
  121.   

crypto/dsa/dsa_lib.c:122:5: 
  120.           return;
  121.   
  122. >     CRYPTO_atomic_add(&r->references, -1, &i, r->lock);
  123.       REF_PRINT_COUNT("DSA", r);
  124.       if (i > 0)

crypto/threads_pthread.c:110:1: start of procedure CRYPTO_atomic_add()
    108.   }
    109.   
    110. > int CRYPTO_atomic_add(int *val, int amount, int *ret, CRYPTO_RWLOCK *lock)
    111.   {
    112.   #ifdef __ATOMIC_RELAXED

crypto/threads_pthread.c:113:5: 
    111.   {
    112.   #ifdef __ATOMIC_RELAXED
    113. >     *ret = __atomic_add_fetch(val, amount, __ATOMIC_RELAXED);
    114.   #else
    115.       if (!CRYPTO_THREAD_write_lock(lock))

crypto/threads_pthread.c:125:5: 
    123.   #endif
    124.   
    125. >     return 1;
    126.   }
    127.   

crypto/threads_pthread.c:126:1: return from a call to CRYPTO_atomic_add
    124.   
    125.       return 1;
    126. > }
    127.   
    128.   #endif

crypto/dsa/dsa_lib.c:124:9: Taking true branch
  122.       CRYPTO_atomic_add(&r->references, -1, &i, r->lock);
  123.       REF_PRINT_COUNT("DSA", r);
  124.       if (i > 0)
                 ^
  125.           return;
  126.       REF_ASSERT_ISNT(i < 0);

crypto/dsa/dsa_lib.c:125:9: 
  123.       REF_PRINT_COUNT("DSA", r);
  124.       if (i > 0)
  125. >         return;
  126.       REF_ASSERT_ISNT(i < 0);
  127.   

crypto/dsa/dsa_lib.c:144:1: return from a call to DSA_free
  142.       BN_clear_free(r->priv_key);
  143.       OPENSSL_free(r);
  144. > }
  145.   
  146.   int DSA_up_ref(DSA *r)
