crypto/bio/bio_lib.c:105: error: MEMORY_LEAK
  memory dynamically allocated by call to `CRYPTO_THREAD_lock_new()` at line 98, column 17 is not reachable after line 105, column 14.
Showing all 59 steps of the trace


crypto/bio/bio_lib.c:80:1: start of procedure BIO_set()
78.   }
79.   
80. > int BIO_set(BIO *bio, const BIO_METHOD *method)
81.   {
82.       bio->method = method;

crypto/bio/bio_lib.c:82:5: 
80.   int BIO_set(BIO *bio, const BIO_METHOD *method)
81.   {
82. >     bio->method = method;
83.       bio->callback = NULL;
84.       bio->cb_arg = NULL;

crypto/bio/bio_lib.c:83:5: 
81.   {
82.       bio->method = method;
83. >     bio->callback = NULL;
84.       bio->cb_arg = NULL;
85.       bio->init = 0;

crypto/bio/bio_lib.c:84:5: 
82.       bio->method = method;
83.       bio->callback = NULL;
84. >     bio->cb_arg = NULL;
85.       bio->init = 0;
86.       bio->shutdown = 1;

crypto/bio/bio_lib.c:85:5: 
83.       bio->callback = NULL;
84.       bio->cb_arg = NULL;
85. >     bio->init = 0;
86.       bio->shutdown = 1;
87.       bio->flags = 0;

crypto/bio/bio_lib.c:86:5: 
84.       bio->cb_arg = NULL;
85.       bio->init = 0;
86. >     bio->shutdown = 1;
87.       bio->flags = 0;
88.       bio->retry_reason = 0;

crypto/bio/bio_lib.c:87:5: 
85.       bio->init = 0;
86.       bio->shutdown = 1;
87. >     bio->flags = 0;
88.       bio->retry_reason = 0;
89.       bio->num = 0;

crypto/bio/bio_lib.c:88:5: 
86.       bio->shutdown = 1;
87.       bio->flags = 0;
88. >     bio->retry_reason = 0;
89.       bio->num = 0;
90.       bio->ptr = NULL;

crypto/bio/bio_lib.c:89:5: 
87.       bio->flags = 0;
88.       bio->retry_reason = 0;
89. >     bio->num = 0;
90.       bio->ptr = NULL;
91.       bio->prev_bio = NULL;

crypto/bio/bio_lib.c:90:5: 
88.       bio->retry_reason = 0;
89.       bio->num = 0;
90. >     bio->ptr = NULL;
91.       bio->prev_bio = NULL;
92.       bio->next_bio = NULL;

crypto/bio/bio_lib.c:91:5: 
89.       bio->num = 0;
90.       bio->ptr = NULL;
91. >     bio->prev_bio = NULL;
92.       bio->next_bio = NULL;
93.       bio->references = 1;

crypto/bio/bio_lib.c:92:5: 
90.       bio->ptr = NULL;
91.       bio->prev_bio = NULL;
92. >     bio->next_bio = NULL;
93.       bio->references = 1;
94.       bio->num_read = 0L;

crypto/bio/bio_lib.c:93:5: 
91.       bio->prev_bio = NULL;
92.       bio->next_bio = NULL;
93. >     bio->references = 1;
94.       bio->num_read = 0L;
95.       bio->num_write = 0L;

crypto/bio/bio_lib.c:94:5: 
92.       bio->next_bio = NULL;
93.       bio->references = 1;
94. >     bio->num_read = 0L;
95.       bio->num_write = 0L;
96.       CRYPTO_new_ex_data(CRYPTO_EX_INDEX_BIO, bio, &bio->ex_data);

crypto/bio/bio_lib.c:95:5: 
93.       bio->references = 1;
94.       bio->num_read = 0L;
95. >     bio->num_write = 0L;
96.       CRYPTO_new_ex_data(CRYPTO_EX_INDEX_BIO, bio, &bio->ex_data);
97.   

crypto/bio/bio_lib.c:96:5: 
94.       bio->num_read = 0L;
95.       bio->num_write = 0L;
96. >     CRYPTO_new_ex_data(CRYPTO_EX_INDEX_BIO, bio, &bio->ex_data);
97.   
98.       bio->lock = CRYPTO_THREAD_lock_new();

crypto/ex_data.c:304:1: start of procedure CRYPTO_new_ex_data()
  302.    * to the global "ex_data" state (ie. class definitions), not 'ad' itself.
  303.    */
  304. > int CRYPTO_new_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad)
  305.   {
  306.       int mx, i;

crypto/ex_data.c:308:5: 
  306.       int mx, i;
  307.       void *ptr;
  308. >     EX_CALLBACK **storage = NULL;
  309.       EX_CALLBACK *stack[10];
  310.       EX_CALLBACKS *ip = get_and_lock(class_index);

crypto/ex_data.c:310:5: 
  308.       EX_CALLBACK **storage = NULL;
  309.       EX_CALLBACK *stack[10];
  310. >     EX_CALLBACKS *ip = get_and_lock(class_index);
  311.   
  312.       if (ip == NULL)

crypto/ex_data.c:149:1: start of procedure get_and_lock()
    147.    * a given class.  On success, *holds the lock.*
    148.    */
    149. > static EX_CALLBACKS *get_and_lock(int class_index)
    150.   {
    151.       EX_CALLBACKS *ip;

crypto/ex_data.c:153:9: Taking false branch
    151.       EX_CALLBACKS *ip;
    152.   
    153.       if (class_index < 0 || class_index >= CRYPTO_EX_INDEX__COUNT) {
                   ^
    154.           CRYPTOerr(CRYPTO_F_GET_AND_LOCK, ERR_R_PASSED_INVALID_ARGUMENT);
    155.           return NULL;

crypto/ex_data.c:153:28: Taking false branch
    151.       EX_CALLBACKS *ip;
    152.   
    153.       if (class_index < 0 || class_index >= CRYPTO_EX_INDEX__COUNT) {
                                      ^
    154.           CRYPTOerr(CRYPTO_F_GET_AND_LOCK, ERR_R_PASSED_INVALID_ARGUMENT);
    155.           return NULL;

crypto/ex_data.c:158:5: 
    156.       }
    157.   
    158. >     CRYPTO_THREAD_run_once(&ex_data_init, do_ex_data_init);
    159.   
    160.       if (ex_data_lock == NULL) {

crypto/threads_pthread.c:104:1: start of procedure CRYPTO_THREAD_run_once()
      102.   }
      103.   
      104. > int CRYPTO_THREAD_run_once(CRYPTO_ONCE *once, void (*init)(void))
      105.   {
      106.       if (pthread_once(once, init) != 0)

crypto/threads_pthread.c:106:9: Taking true branch
      104.   int CRYPTO_THREAD_run_once(CRYPTO_ONCE *once, void (*init)(void))
      105.   {
      106.       if (pthread_once(once, init) != 0)
                     ^
      107.           return 0;
      108.   

crypto/threads_pthread.c:107:9: 
      105.   {
      106.       if (pthread_once(once, init) != 0)
      107. >         return 0;
      108.   
      109.       return 1;

crypto/threads_pthread.c:110:1: return from a call to CRYPTO_THREAD_run_once
      108.   
      109.       return 1;
      110. > }
      111.   
      112.   int CRYPTO_THREAD_init_local(CRYPTO_THREAD_LOCAL *key, void (*cleanup)(void *))

crypto/ex_data.c:160:9: Taking true branch
    158.       CRYPTO_THREAD_run_once(&ex_data_init, do_ex_data_init);
    159.   
    160.       if (ex_data_lock == NULL) {
                   ^
    161.           /*
    162.            * This can happen in normal operation when using CRYPTO_mem_leaks().

crypto/ex_data.c:170:10: 
    168.            * ignore this operation. We just treat it as an error.
    169.            */
    170. >          return NULL;
    171.       }
    172.   

crypto/ex_data.c:176:1: return from a call to get_and_lock
    174.       CRYPTO_THREAD_write_lock(ex_data_lock);
    175.       return ip;
    176. > }
    177.   
    178.   static void cleanup_cb(EX_CALLBACK *funcs)

crypto/ex_data.c:312:9: Taking true branch
  310.       EX_CALLBACKS *ip = get_and_lock(class_index);
  311.   
  312.       if (ip == NULL)
                 ^
  313.           return 0;
  314.   

crypto/ex_data.c:313:9: 
  311.   
  312.       if (ip == NULL)
  313. >         return 0;
  314.   
  315.       ad->sk = NULL;

crypto/ex_data.c:343:1: return from a call to CRYPTO_new_ex_data
  341.           OPENSSL_free(storage);
  342.       return 1;
  343. > }
  344.   
  345.   /*

crypto/bio/bio_lib.c:98:5: 
96.       CRYPTO_new_ex_data(CRYPTO_EX_INDEX_BIO, bio, &bio->ex_data);
97.   
98. >     bio->lock = CRYPTO_THREAD_lock_new();
99.       if (bio->lock == NULL) {
100.           CRYPTO_free_ex_data(CRYPTO_EX_INDEX_BIO, bio, &bio->ex_data);

crypto/threads_pthread.c:55:1: start of procedure CRYPTO_THREAD_lock_new()
  53.   #if defined(OPENSSL_THREADS) && !defined(CRYPTO_TDEBUG) && !defined(OPENSSL_SYS_WINDOWS)
  54.   
  55. > CRYPTO_RWLOCK *CRYPTO_THREAD_lock_new(void)
  56.   {
  57.       CRYPTO_RWLOCK *lock = OPENSSL_zalloc(sizeof(pthread_rwlock_t));

crypto/threads_pthread.c:57:5: 
  55.   CRYPTO_RWLOCK *CRYPTO_THREAD_lock_new(void)
  56.   {
  57. >     CRYPTO_RWLOCK *lock = OPENSSL_zalloc(sizeof(pthread_rwlock_t));
  58.       if (lock == NULL)
  59.           return NULL;

crypto/mem.c:146:1: start of procedure CRYPTO_zalloc()
    144.   }
    145.   
    146. > void *CRYPTO_zalloc(size_t num, const char *file, int line)
    147.   {
    148.       void *ret = CRYPTO_malloc(num, file, line);

crypto/mem.c:148:5: 
    146.   void *CRYPTO_zalloc(size_t num, const char *file, int line)
    147.   {
    148. >     void *ret = CRYPTO_malloc(num, file, line);
    149.   
    150.       if (ret != NULL)

crypto/mem.c:119:1: start of procedure CRYPTO_malloc()
      117.   }
      118.   
      119. > void *CRYPTO_malloc(size_t num, const char *file, int line)
      120.   {
      121.       void *ret = NULL;

crypto/mem.c:121:5: 
      119.   void *CRYPTO_malloc(size_t num, const char *file, int line)
      120.   {
      121. >     void *ret = NULL;
      122.   
      123.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)

crypto/mem.c:123:9: Taking false branch
      121.       void *ret = NULL;
      122.   
      123.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
                     ^
      124.           return malloc_impl(num, file, line);
      125.   

crypto/mem.c:126:9: Taking false branch
      124.           return malloc_impl(num, file, line);
      125.   
      126.       if (num <= 0)
                     ^
      127.           return NULL;
      128.   

crypto/mem.c:129:5: 
      127.           return NULL;
      128.   
      129. >     allow_customize = 0;
      130.   #ifndef OPENSSL_NO_CRYPTO_MDEBUG
      131.       if (call_malloc_debug) {

crypto/mem.c:139:5: 
      137.       }
      138.   #else
      139. >     osslargused(file); osslargused(line);
      140.       ret = malloc(num);
      141.   #endif

crypto/mem.c:139:24: 
      137.       }
      138.   #else
      139. >     osslargused(file); osslargused(line);
      140.       ret = malloc(num);
      141.   #endif

crypto/mem.c:140:5: 
      138.   #else
      139.       osslargused(file); osslargused(line);
      140. >     ret = malloc(num);
      141.   #endif
      142.   

crypto/mem.c:143:5: 
      141.   #endif
      142.   
      143. >     return ret;
      144.   }
      145.   

crypto/mem.c:144:1: return from a call to CRYPTO_malloc
      142.   
      143.       return ret;
      144. > }
      145.   
      146.   void *CRYPTO_zalloc(size_t num, const char *file, int line)

crypto/mem.c:150:9: Taking true branch
    148.       void *ret = CRYPTO_malloc(num, file, line);
    149.   
    150.       if (ret != NULL)
                   ^
    151.           memset(ret, 0, num);
    152.       return ret;

crypto/mem.c:151:9: 
    149.   
    150.       if (ret != NULL)
    151. >         memset(ret, 0, num);
    152.       return ret;
    153.   }

crypto/mem.c:152:5: 
    150.       if (ret != NULL)
    151.           memset(ret, 0, num);
    152. >     return ret;
    153.   }
    154.   

crypto/mem.c:153:1: return from a call to CRYPTO_zalloc
    151.           memset(ret, 0, num);
    152.       return ret;
    153. > }
    154.   
    155.   void *CRYPTO_realloc(void *str, size_t num, const char *file, int line)

crypto/threads_pthread.c:58:9: Taking false branch
  56.   {
  57.       CRYPTO_RWLOCK *lock = OPENSSL_zalloc(sizeof(pthread_rwlock_t));
  58.       if (lock == NULL)
                ^
  59.           return NULL;
  60.   

crypto/threads_pthread.c:61:9: Taking false branch
  59.           return NULL;
  60.   
  61.       if (pthread_rwlock_init(lock, NULL) != 0) {
                ^
  62.           OPENSSL_free(lock);
  63.           return NULL;

crypto/threads_pthread.c:66:5: 
  64.       }
  65.   
  66. >     return lock;
  67.   }
  68.   

crypto/threads_pthread.c:67:1: return from a call to CRYPTO_THREAD_lock_new
  65.   
  66.       return lock;
  67. > }
  68.   
  69.   int CRYPTO_THREAD_read_lock(CRYPTO_RWLOCK *lock)

crypto/bio/bio_lib.c:99:9: Taking false branch
97.   
98.       bio->lock = CRYPTO_THREAD_lock_new();
99.       if (bio->lock == NULL) {
               ^
100.           CRYPTO_free_ex_data(CRYPTO_EX_INDEX_BIO, bio, &bio->ex_data);
101.           return 0;

crypto/bio/bio_lib.c:104:9: Taking true branch
102.       }
103.   
104.       if (method->create != NULL) {
               ^
105.           if (!method->create(bio)) {
106.               CRYPTO_free_ex_data(CRYPTO_EX_INDEX_BIO, bio, &bio->ex_data);

crypto/bio/bio_lib.c:105:14: Skipping __function_pointer__(): unresolved function pointer
103.   
104.       if (method->create != NULL) {
105.           if (!method->create(bio)) {
                    ^
106.               CRYPTO_free_ex_data(CRYPTO_EX_INDEX_BIO, bio, &bio->ex_data);
107.               CRYPTO_THREAD_lock_free(bio->lock);

int BIO_set(BIO *bio, const BIO_METHOD *method)
{
    bio->method = method;
    bio->callback = NULL;
    bio->cb_arg = NULL;
    bio->init = 0;
    bio->shutdown = 1;
    bio->flags = 0;
    bio->retry_reason = 0;
    bio->num = 0;
    bio->ptr = NULL;
    bio->prev_bio = NULL;
    bio->next_bio = NULL;
    bio->references = 1;
    bio->num_read = 0L;
    bio->num_write = 0L;
    CRYPTO_new_ex_data(CRYPTO_EX_INDEX_BIO, bio, &bio->ex_data);
    bio->lock = CRYPTO_THREAD_lock_new();
    if (bio->lock == NULL) {
        CRYPTO_free_ex_data(CRYPTO_EX_INDEX_BIO, bio, &bio->ex_data);
        return 0;
    }
    if (method->create != NULL) {
        if (!method->create(bio)) {
            CRYPTO_free_ex_data(CRYPTO_EX_INDEX_BIO, bio, &bio->ex_data);
            CRYPTO_THREAD_lock_free(bio->lock);
            return 0;
        }
    }
    return 1;
}
['int BIO_set(BIO *bio, const BIO_METHOD *method)\n{\n    bio->method = method;\n    bio->callback = NULL;\n    bio->cb_arg = NULL;\n    bio->init = 0;\n    bio->shutdown = 1;\n    bio->flags = 0;\n    bio->retry_reason = 0;\n    bio->num = 0;\n    bio->ptr = NULL;\n    bio->prev_bio = NULL;\n    bio->next_bio = NULL;\n    bio->references = 1;\n    bio->num_read = 0L;\n    bio->num_write = 0L;\n    CRYPTO_new_ex_data(CRYPTO_EX_INDEX_BIO, bio, &bio->ex_data);\n    bio->lock = CRYPTO_THREAD_lock_new();\n    if (bio->lock == NULL) {\n        CRYPTO_free_ex_data(CRYPTO_EX_INDEX_BIO, bio, &bio->ex_data);\n        return 0;\n    }\n    if (method->create != NULL) {\n        if (!method->create(bio)) {\n            CRYPTO_free_ex_data(CRYPTO_EX_INDEX_BIO, bio, &bio->ex_data);\n            CRYPTO_THREAD_lock_free(bio->lock);\n            return 0;\n        }\n    }\n    return 1;\n}', 'int CRYPTO_new_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad)\n{\n    int mx, i;\n    void *ptr;\n    EX_CALLBACK **storage = NULL;\n    EX_CALLBACK *stack[10];\n    EX_CALLBACKS *ip = get_and_lock(class_index);\n    if (ip == NULL)\n        return 0;\n    ad->sk = NULL;\n    mx = sk_EX_CALLBACK_num(ip->meth);\n    if (mx > 0) {\n        if (mx < (int)OSSL_NELEM(stack))\n            storage = stack;\n        else\n            storage = OPENSSL_malloc(sizeof(*storage) * mx);\n        if (storage != NULL)\n            for (i = 0; i < mx; i++)\n                storage[i] = sk_EX_CALLBACK_value(ip->meth, i);\n    }\n    CRYPTO_THREAD_unlock(ex_data_lock);\n    if (mx > 0 && storage == NULL) {\n        CRYPTOerr(CRYPTO_F_CRYPTO_NEW_EX_DATA, ERR_R_MALLOC_FAILURE);\n        return 0;\n    }\n    for (i = 0; i < mx; i++) {\n        if (storage[i] && storage[i]->new_func) {\n            ptr = CRYPTO_get_ex_data(ad, i);\n            storage[i]->new_func(obj, ptr, ad, i,\n                                 storage[i]->argl, storage[i]->argp);\n        }\n    }\n    if (storage != stack)\n        OPENSSL_free(storage);\n    return 1;\n}', 'static EX_CALLBACKS *get_and_lock(int class_index)\n{\n    EX_CALLBACKS *ip;\n    if (class_index < 0 || class_index >= CRYPTO_EX_INDEX__COUNT) {\n        CRYPTOerr(CRYPTO_F_GET_AND_LOCK, ERR_R_PASSED_INVALID_ARGUMENT);\n        return NULL;\n    }\n    CRYPTO_THREAD_run_once(&ex_data_init, do_ex_data_init);\n    if (ex_data_lock == NULL) {\n         return NULL;\n    }\n    ip = &ex_data[class_index];\n    CRYPTO_THREAD_write_lock(ex_data_lock);\n    return ip;\n}', 'int CRYPTO_THREAD_run_once(CRYPTO_ONCE *once, void (*init)(void))\n{\n    if (pthread_once(once, init) != 0)\n        return 0;\n    return 1;\n}', 'CRYPTO_RWLOCK *CRYPTO_THREAD_lock_new(void)\n{\n    CRYPTO_RWLOCK *lock = OPENSSL_zalloc(sizeof(pthread_rwlock_t));\n    if (lock == NULL)\n        return NULL;\n    if (pthread_rwlock_init(lock, NULL) != 0) {\n        OPENSSL_free(lock);\n        return NULL;\n    }\n    return lock;\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 (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)\n        return malloc_impl(num, file, line);\n    if (num <= 0)\n        return NULL;\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}']