crypto/ui/ui_lib.c:45: error: MEMORY_LEAK
  memory dynamically allocated by call to `CRYPTO_THREAD_lock_new()` at line 32, column 17 is not reachable after line 45, column 9.
Showing all 71 steps of the trace


crypto/ui/ui_lib.c:23:1: start of procedure UI_new_method()
21.   }
22.   
23. > UI *UI_new_method(const UI_METHOD *method)
24.   {
25.       UI *ret = OPENSSL_zalloc(sizeof(*ret));

crypto/ui/ui_lib.c:25:5: 
23.   UI *UI_new_method(const UI_METHOD *method)
24.   {
25. >     UI *ret = OPENSSL_zalloc(sizeof(*ret));
26.   
27.       if (ret == NULL) {

crypto/mem.c:194:1: start of procedure CRYPTO_zalloc()
  192.   }
  193.   
  194. > void *CRYPTO_zalloc(size_t num, const char *file, int line)
  195.   {
  196.       void *ret = CRYPTO_malloc(num, file, line);

crypto/mem.c:196:5: 
  194.   void *CRYPTO_zalloc(size_t num, const char *file, int line)
  195.   {
  196. >     void *ret = CRYPTO_malloc(num, file, line);
  197.   
  198.       FAILTEST();

crypto/mem.c:166:1: start of procedure CRYPTO_malloc()
    164.   #endif
    165.   
    166. > void *CRYPTO_malloc(size_t num, const char *file, int line)
    167.   {
    168.       void *ret = NULL;

crypto/mem.c:168:5: 
    166.   void *CRYPTO_malloc(size_t num, const char *file, int line)
    167.   {
    168. >     void *ret = NULL;
    169.   
    170.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)

crypto/mem.c:170:9: Taking false branch
    168.       void *ret = NULL;
    169.   
    170.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
                   ^
    171.           return malloc_impl(num, file, line);
    172.   

crypto/mem.c:173:9: Taking false branch
    171.           return malloc_impl(num, file, line);
    172.   
    173.       if (num == 0)
                   ^
    174.           return NULL;
    175.   

crypto/mem.c:177:5: 
    175.   
    176.       FAILTEST();
    177. >     allow_customize = 0;
    178.   #ifndef OPENSSL_NO_CRYPTO_MDEBUG
    179.       if (call_malloc_debug) {

crypto/mem.c:187:5: 
    185.       }
    186.   #else
    187. >     osslargused(file); osslargused(line);
    188.       ret = malloc(num);
    189.   #endif

crypto/mem.c:187:24: 
    185.       }
    186.   #else
    187. >     osslargused(file); osslargused(line);
    188.       ret = malloc(num);
    189.   #endif

crypto/mem.c:188:5: 
    186.   #else
    187.       osslargused(file); osslargused(line);
    188. >     ret = malloc(num);
    189.   #endif
    190.   

crypto/mem.c:191:5: 
    189.   #endif
    190.   
    191. >     return ret;
    192.   }
    193.   

crypto/mem.c:192:1: return from a call to CRYPTO_malloc
    190.   
    191.       return ret;
    192. > }
    193.   
    194.   void *CRYPTO_zalloc(size_t num, const char *file, int line)

crypto/mem.c:199:9: Taking true branch
  197.   
  198.       FAILTEST();
  199.       if (ret != NULL)
                 ^
  200.           memset(ret, 0, num);
  201.       return ret;

crypto/mem.c:200:9: 
  198.       FAILTEST();
  199.       if (ret != NULL)
  200. >         memset(ret, 0, num);
  201.       return ret;
  202.   }

crypto/mem.c:201:5: 
  199.       if (ret != NULL)
  200.           memset(ret, 0, num);
  201. >     return ret;
  202.   }
  203.   

crypto/mem.c:202:1: return from a call to CRYPTO_zalloc
  200.           memset(ret, 0, num);
  201.       return ret;
  202. > }
  203.   
  204.   void *CRYPTO_realloc(void *str, size_t num, const char *file, int line)

crypto/ui/ui_lib.c:27:9: Taking false branch
25.       UI *ret = OPENSSL_zalloc(sizeof(*ret));
26.   
27.       if (ret == NULL) {
              ^
28.           UIerr(UI_F_UI_NEW_METHOD, ERR_R_MALLOC_FAILURE);
29.           return NULL;

crypto/ui/ui_lib.c:32:5: 
30.       }
31.   
32. >     ret->lock = CRYPTO_THREAD_lock_new();
33.       if (ret->lock == NULL) {
34.           UIerr(UI_F_UI_NEW_METHOD, ERR_R_MALLOC_FAILURE);

crypto/threads_pthread.c:19:1: start of procedure CRYPTO_THREAD_lock_new()
  17.   # endif
  18.   
  19. > CRYPTO_RWLOCK *CRYPTO_THREAD_lock_new(void)
  20.   {
  21.   # ifdef USE_RWLOCK

crypto/threads_pthread.c:22:5: 
  20.   {
  21.   # ifdef USE_RWLOCK
  22. >     CRYPTO_RWLOCK *lock = OPENSSL_zalloc(sizeof(pthread_rwlock_t));
  23.       if (lock == NULL)
  24.           return NULL;

crypto/mem.c:194:1: start of procedure CRYPTO_zalloc()
    192.   }
    193.   
    194. > void *CRYPTO_zalloc(size_t num, const char *file, int line)
    195.   {
    196.       void *ret = CRYPTO_malloc(num, file, line);

crypto/mem.c:196:5: 
    194.   void *CRYPTO_zalloc(size_t num, const char *file, int line)
    195.   {
    196. >     void *ret = CRYPTO_malloc(num, file, line);
    197.   
    198.       FAILTEST();

crypto/mem.c:166:1: start of procedure CRYPTO_malloc()
      164.   #endif
      165.   
      166. > void *CRYPTO_malloc(size_t num, const char *file, int line)
      167.   {
      168.       void *ret = NULL;

crypto/mem.c:168:5: 
      166.   void *CRYPTO_malloc(size_t num, const char *file, int line)
      167.   {
      168. >     void *ret = NULL;
      169.   
      170.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)

crypto/mem.c:170:9: Taking false branch
      168.       void *ret = NULL;
      169.   
      170.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
                     ^
      171.           return malloc_impl(num, file, line);
      172.   

crypto/mem.c:173:9: Taking false branch
      171.           return malloc_impl(num, file, line);
      172.   
      173.       if (num == 0)
                     ^
      174.           return NULL;
      175.   

crypto/mem.c:177:5: 
      175.   
      176.       FAILTEST();
      177. >     allow_customize = 0;
      178.   #ifndef OPENSSL_NO_CRYPTO_MDEBUG
      179.       if (call_malloc_debug) {

crypto/mem.c:187:5: 
      185.       }
      186.   #else
      187. >     osslargused(file); osslargused(line);
      188.       ret = malloc(num);
      189.   #endif

crypto/mem.c:187:24: 
      185.       }
      186.   #else
      187. >     osslargused(file); osslargused(line);
      188.       ret = malloc(num);
      189.   #endif

crypto/mem.c:188:5: 
      186.   #else
      187.       osslargused(file); osslargused(line);
      188. >     ret = malloc(num);
      189.   #endif
      190.   

crypto/mem.c:191:5: 
      189.   #endif
      190.   
      191. >     return ret;
      192.   }
      193.   

crypto/mem.c:192:1: return from a call to CRYPTO_malloc
      190.   
      191.       return ret;
      192. > }
      193.   
      194.   void *CRYPTO_zalloc(size_t num, const char *file, int line)

crypto/mem.c:199:9: Taking true branch
    197.   
    198.       FAILTEST();
    199.       if (ret != NULL)
                   ^
    200.           memset(ret, 0, num);
    201.       return ret;

crypto/mem.c:200:9: 
    198.       FAILTEST();
    199.       if (ret != NULL)
    200. >         memset(ret, 0, num);
    201.       return ret;
    202.   }

crypto/mem.c:201:5: 
    199.       if (ret != NULL)
    200.           memset(ret, 0, num);
    201. >     return ret;
    202.   }
    203.   

crypto/mem.c:202:1: return from a call to CRYPTO_zalloc
    200.           memset(ret, 0, num);
    201.       return ret;
    202. > }
    203.   
    204.   void *CRYPTO_realloc(void *str, size_t num, const char *file, int line)

crypto/threads_pthread.c:23:9: Taking false branch
  21.   # ifdef USE_RWLOCK
  22.       CRYPTO_RWLOCK *lock = OPENSSL_zalloc(sizeof(pthread_rwlock_t));
  23.       if (lock == NULL)
                ^
  24.           return NULL;
  25.   

crypto/threads_pthread.c:26:9: Taking false branch
  24.           return NULL;
  25.   
  26.       if (pthread_rwlock_init(lock, NULL) != 0) {
                ^
  27.           OPENSSL_free(lock);
  28.           return NULL;

crypto/threads_pthread.c:48:5: 
  46.   # endif
  47.   
  48. >     return lock;
  49.   }
  50.   

crypto/threads_pthread.c:49:1: return from a call to CRYPTO_THREAD_lock_new
  47.   
  48.       return lock;
  49. > }
  50.   
  51.   int CRYPTO_THREAD_read_lock(CRYPTO_RWLOCK *lock)

crypto/ui/ui_lib.c:33:9: Taking false branch
31.   
32.       ret->lock = CRYPTO_THREAD_lock_new();
33.       if (ret->lock == NULL) {
              ^
34.           UIerr(UI_F_UI_NEW_METHOD, ERR_R_MALLOC_FAILURE);
35.           OPENSSL_free(ret);

crypto/ui/ui_lib.c:39:9: Taking false branch
37.       }
38.   
39.       if (method == NULL)
              ^
40.           ret->meth = UI_get_default_method();
41.       else

crypto/ui/ui_lib.c:42:9: 
40.           ret->meth = UI_get_default_method();
41.       else
42. >         ret->meth = method;
43.   
44.       if (!CRYPTO_new_ex_data(CRYPTO_EX_INDEX_UI, ret, &ret->ex_data)) {

crypto/ui/ui_lib.c:44:10: 
42.           ret->meth = method;
43.   
44. >     if (!CRYPTO_new_ex_data(CRYPTO_EX_INDEX_UI, ret, &ret->ex_data)) {
45.           OPENSSL_free(ret);
46.           return NULL;

crypto/ex_data.c:208:1: start of procedure CRYPTO_new_ex_data()
  206.    * to the global "ex_data" state (ie. class definitions), not 'ad' itself.
  207.    */
  208. > int CRYPTO_new_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad)
  209.   {
  210.       int mx, i;

crypto/ex_data.c:212:5: 
  210.       int mx, i;
  211.       void *ptr;
  212. >     EX_CALLBACK **storage = NULL;
  213.       EX_CALLBACK *stack[10];
  214.       EX_CALLBACKS *ip = get_and_lock(class_index);

crypto/ex_data.c:214:5: 
  212.       EX_CALLBACK **storage = NULL;
  213.       EX_CALLBACK *stack[10];
  214. >     EX_CALLBACKS *ip = get_and_lock(class_index);
  215.   
  216.       if (ip == NULL)

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

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

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

crypto/ex_data.c:59:10: 
    57.       }
    58.   
    59. >     if (!RUN_ONCE(&ex_data_init, do_ex_data_init)) {
    60.           CRYPTOerr(CRYPTO_F_GET_AND_LOCK, ERR_R_MALLOC_FAILURE);
    61.           return NULL;

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

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

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

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

crypto/ex_data.c:59:10: Condition is false
    57.       }
    58.   
    59.       if (!RUN_ONCE(&ex_data_init, do_ex_data_init)) {
                   ^
    60.           CRYPTOerr(CRYPTO_F_GET_AND_LOCK, ERR_R_MALLOC_FAILURE);
    61.           return NULL;

crypto/ex_data.c:59:10: Taking true branch
    57.       }
    58.   
    59.       if (!RUN_ONCE(&ex_data_init, do_ex_data_init)) {
                   ^
    60.           CRYPTOerr(CRYPTO_F_GET_AND_LOCK, ERR_R_MALLOC_FAILURE);
    61.           return NULL;

crypto/ex_data.c:60:9: Skipping ERR_put_error(): empty list of specs
    58.   
    59.       if (!RUN_ONCE(&ex_data_init, do_ex_data_init)) {
    60.           CRYPTOerr(CRYPTO_F_GET_AND_LOCK, ERR_R_MALLOC_FAILURE);
                  ^
    61.           return NULL;
    62.       }

crypto/ex_data.c:61:9: 
    59.       if (!RUN_ONCE(&ex_data_init, do_ex_data_init)) {
    60.           CRYPTOerr(CRYPTO_F_GET_AND_LOCK, ERR_R_MALLOC_FAILURE);
    61. >         return NULL;
    62.       }
    63.   

crypto/ex_data.c:80:1: return from a call to get_and_lock
    78.       CRYPTO_THREAD_write_lock(ex_data_lock);
    79.       return ip;
    80. > }
    81.   
    82.   static void cleanup_cb(EX_CALLBACK *funcs)

crypto/ex_data.c:216:9: Taking true branch
  214.       EX_CALLBACKS *ip = get_and_lock(class_index);
  215.   
  216.       if (ip == NULL)
                 ^
  217.           return 0;
  218.   

crypto/ex_data.c:217:9: 
  215.   
  216.       if (ip == NULL)
  217. >         return 0;
  218.   
  219.       ad->sk = NULL;

crypto/ex_data.c:247:1: return from a call to CRYPTO_new_ex_data
  245.           OPENSSL_free(storage);
  246.       return 1;
  247. > }
  248.   
  249.   /*

crypto/ui/ui_lib.c:44:10: Taking true branch
42.           ret->meth = method;
43.   
44.       if (!CRYPTO_new_ex_data(CRYPTO_EX_INDEX_UI, ret, &ret->ex_data)) {
               ^
45.           OPENSSL_free(ret);
46.           return NULL;

crypto/ui/ui_lib.c:45:9: 
43.   
44.       if (!CRYPTO_new_ex_data(CRYPTO_EX_INDEX_UI, ret, &ret->ex_data)) {
45. >         OPENSSL_free(ret);
46.           return NULL;
47.       }

crypto/mem.c:261:1: start of procedure CRYPTO_free()
  259.   }
  260.   
  261. > void CRYPTO_free(void *str, const char *file, int line)
  262.   {
  263.       if (free_impl != NULL && free_impl != &CRYPTO_free) {

crypto/mem.c:263:9: Taking false branch
  261.   void CRYPTO_free(void *str, const char *file, int line)
  262.   {
  263.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
                 ^
  264.           free_impl(str, file, line);
  265.           return;

crypto/mem.c:277:5: 
  275.       }
  276.   #else
  277. >     free(str);
  278.   #endif
  279.   }

crypto/mem.c:279:1: return from a call to CRYPTO_free
  277.       free(str);
  278.   #endif
  279. > }
  280.   
  281.   void CRYPTO_clear_free(void *str, size_t num, const char *file, int line)

UI *UI_new_method(const UI_METHOD *method)
{
    UI *ret = OPENSSL_zalloc(sizeof(*ret));
    if (ret == NULL) {
        UIerr(UI_F_UI_NEW_METHOD, ERR_R_MALLOC_FAILURE);
        return NULL;
    }
    ret->lock = CRYPTO_THREAD_lock_new();
    if (ret->lock == NULL) {
        UIerr(UI_F_UI_NEW_METHOD, ERR_R_MALLOC_FAILURE);
        OPENSSL_free(ret);
        return NULL;
    }
    if (method == NULL)
        ret->meth = UI_get_default_method();
    else
        ret->meth = method;
    if (!CRYPTO_new_ex_data(CRYPTO_EX_INDEX_UI, ret, &ret->ex_data)) {
        OPENSSL_free(ret);
        return NULL;
    }
    return ret;
}
['UI *UI_new_method(const UI_METHOD *method)\n{\n    UI *ret = OPENSSL_zalloc(sizeof(*ret));\n    if (ret == NULL) {\n        UIerr(UI_F_UI_NEW_METHOD, ERR_R_MALLOC_FAILURE);\n        return NULL;\n    }\n    ret->lock = CRYPTO_THREAD_lock_new();\n    if (ret->lock == NULL) {\n        UIerr(UI_F_UI_NEW_METHOD, ERR_R_MALLOC_FAILURE);\n        OPENSSL_free(ret);\n        return NULL;\n    }\n    if (method == NULL)\n        ret->meth = UI_get_default_method();\n    else\n        ret->meth = method;\n    if (!CRYPTO_new_ex_data(CRYPTO_EX_INDEX_UI, ret, &ret->ex_data)) {\n        OPENSSL_free(ret);\n        return NULL;\n    }\n    return ret;\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}', 'CRYPTO_RWLOCK *CRYPTO_THREAD_lock_new(void)\n{\n# ifdef USE_RWLOCK\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# else\n    pthread_mutexattr_t attr;\n    CRYPTO_RWLOCK *lock = OPENSSL_zalloc(sizeof(pthread_mutex_t));\n    if (lock == NULL)\n        return NULL;\n    pthread_mutexattr_init(&attr);\n    pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);\n    if (pthread_mutex_init(lock, &attr) != 0) {\n        pthread_mutexattr_destroy(&attr);\n        OPENSSL_free(lock);\n        return NULL;\n    }\n    pthread_mutexattr_destroy(&attr);\n# endif\n    return lock;\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    if (!RUN_ONCE(&ex_data_init, do_ex_data_init)) {\n        CRYPTOerr(CRYPTO_F_GET_AND_LOCK, ERR_R_MALLOC_FAILURE);\n        return NULL;\n    }\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}', '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}']