crypto/err/err.c:286: error: MEMORY_LEAK
  memory dynamically allocated to `err_string_lock` by call to `CRYPTO_THREAD_lock_new()` at line 279, column 23 is not reachable after line 286, column 9.
Showing all 45 steps of the trace


crypto/err/err.c:275:1: start of procedure do_err_strings_init()
273.   }
274.   
275. > DEFINE_RUN_ONCE_STATIC(do_err_strings_init)
276.   {
277.       if (!OPENSSL_init_crypto(0, NULL))

crypto/err/err.c:277:10: Taking false branch
275.   DEFINE_RUN_ONCE_STATIC(do_err_strings_init)
276.   {
277.       if (!OPENSSL_init_crypto(0, NULL))
                ^
278.           return 0;
279.       err_string_lock = CRYPTO_THREAD_lock_new();

crypto/err/err.c:279:5: 
277.       if (!OPENSSL_init_crypto(0, NULL))
278.           return 0;
279. >     err_string_lock = CRYPTO_THREAD_lock_new();
280.       if (err_string_lock == NULL)
281.           return 0;

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:24:9: 
  22.       CRYPTO_RWLOCK *lock;
  23.   
  24. >     if ((lock = OPENSSL_zalloc(sizeof(pthread_rwlock_t))) == NULL) {
  25.           /* Don't set error, to avoid recursion blowup. */
  26.           return 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.   #ifndef OPENSSL_NO_CRYPTO_MDEBUG

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/threads_pthread.c:24:9: Taking false branch
  22.       CRYPTO_RWLOCK *lock;
  23.   
  24.       if ((lock = OPENSSL_zalloc(sizeof(pthread_rwlock_t))) == NULL) {
                ^
  25.           /* Don't set error, to avoid recursion blowup. */
  26.           return NULL;

crypto/threads_pthread.c:29:9: Taking false branch
  27.       }
  28.   
  29.       if (pthread_rwlock_init(lock, NULL) != 0) {
                ^
  30.           OPENSSL_free(lock);
  31.           return NULL;

crypto/threads_pthread.c:54:5: 
  52.   # endif
  53.   
  54. >     return lock;
  55.   }
  56.   

crypto/threads_pthread.c:55:1: return from a call to CRYPTO_THREAD_lock_new
  53.   
  54.       return lock;
  55. > }
  56.   
  57.   int CRYPTO_THREAD_read_lock(CRYPTO_RWLOCK *lock)

crypto/err/err.c:280:9: Taking false branch
278.           return 0;
279.       err_string_lock = CRYPTO_THREAD_lock_new();
280.       if (err_string_lock == NULL)
               ^
281.           return 0;
282.       int_error_hash = lh_ERR_STRING_DATA_new(err_string_data_hash,

crypto/err/err.c:282:5: 
280.       if (err_string_lock == NULL)
281.           return 0;
282. >     int_error_hash = lh_ERR_STRING_DATA_new(err_string_data_hash,
283.                                               err_string_data_cmp);
284.       if (int_error_hash == NULL) {

include/openssl/err.h:217:1: start of procedure lh_ERR_STRING_DATA_new()
  215.   } ERR_STRING_DATA;
  216.   
  217. > DEFINE_LHASH_OF(ERR_STRING_DATA);
  218.   
  219.   void ERR_put_error(int lib, int func, int reason, const char *file, int line);

include/openssl/err.h:217:1: return from a call to lh_ERR_STRING_DATA_new
  215.   } ERR_STRING_DATA;
  216.   
  217. > DEFINE_LHASH_OF(ERR_STRING_DATA);
  218.   
  219.   void ERR_put_error(int lib, int func, int reason, const char *file, int line);

crypto/err/err.c:284:9: Taking true branch
282.       int_error_hash = lh_ERR_STRING_DATA_new(err_string_data_hash,
283.                                               err_string_data_cmp);
284.       if (int_error_hash == NULL) {
               ^
285.           CRYPTO_THREAD_lock_free(err_string_lock);
286.           err_string_lock = NULL;

crypto/err/err.c:285:9: 
283.                                               err_string_data_cmp);
284.       if (int_error_hash == NULL) {
285. >         CRYPTO_THREAD_lock_free(err_string_lock);
286.           err_string_lock = NULL;
287.           return 0;

crypto/threads_pthread.c:96:1: start of procedure CRYPTO_THREAD_lock_free()
  94.   }
  95.   
  96. > void CRYPTO_THREAD_lock_free(CRYPTO_RWLOCK *lock)
  97.   {
  98.       if (lock == NULL)

crypto/threads_pthread.c:98:9: Taking false branch
  96.   void CRYPTO_THREAD_lock_free(CRYPTO_RWLOCK *lock)
  97.   {
  98.       if (lock == NULL)
                 ^
  99.           return;
  100.   

crypto/threads_pthread.c:102:5: Skipping pthread_rwlock_destroy(): method has no implementation
  100.   
  101.   # ifdef USE_RWLOCK
  102.       pthread_rwlock_destroy(lock);
             ^
  103.   # else
  104.       pthread_mutex_destroy(lock);

crypto/threads_pthread.c:106:5: 
  104.       pthread_mutex_destroy(lock);
  105.   # endif
  106. >     OPENSSL_free(lock);
  107.   
  108.       return;

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/threads_pthread.c:108:5: 
  106.       OPENSSL_free(lock);
  107.   
  108. >     return;
  109.   }
  110.   

crypto/threads_pthread.c:109:1: return from a call to CRYPTO_THREAD_lock_free
  107.   
  108.       return;
  109. > }
  110.   
  111.   int CRYPTO_THREAD_run_once(CRYPTO_ONCE *once, void (*init)(void))

crypto/err/err.c:286:9: 
284.       if (int_error_hash == NULL) {
285.           CRYPTO_THREAD_lock_free(err_string_lock);
286. >         err_string_lock = NULL;
287.           return 0;
288.       }

DEFINE_RUN_ONCE_STATIC(do_err_strings_init)
{
    if (!OPENSSL_init_crypto(0, NULL))
        return 0;
    err_string_lock = CRYPTO_THREAD_lock_new();
    if (err_string_lock == NULL)
        return 0;
    int_error_hash = lh_ERR_STRING_DATA_new(err_string_data_hash,
                                            err_string_data_cmp);
    if (int_error_hash == NULL) {
        CRYPTO_THREAD_lock_free(err_string_lock);
        err_string_lock = NULL;
        return 0;
    }
    return 1;
}
['DEFINE_RUN_ONCE_STATIC(do_err_strings_init)', 'DEFINE_RUN_ONCE_STATIC(do_err_strings_init)\n{\n    if (!OPENSSL_init_crypto(0, NULL))\n        return 0;\n    err_string_lock = CRYPTO_THREAD_lock_new();\n    if (err_string_lock == NULL)\n        return 0;\n    int_error_hash = lh_ERR_STRING_DATA_new(err_string_data_hash,\n                                            err_string_data_cmp);\n    if (int_error_hash == NULL) {\n        CRYPTO_THREAD_lock_free(err_string_lock);\n        err_string_lock = NULL;\n        return 0;\n    }\n    return 1;\n}', 'CRYPTO_RWLOCK *CRYPTO_THREAD_lock_new(void)\n{\n# ifdef USE_RWLOCK\n    CRYPTO_RWLOCK *lock;\n    if ((lock = OPENSSL_zalloc(sizeof(pthread_rwlock_t))) == NULL) {\n        return NULL;\n    }\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;\n    if ((lock = OPENSSL_zalloc(sizeof(pthread_mutex_t))) == NULL) {\n        return NULL;\n    }\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}', '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#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    (void)(file); (void)(line);\n    ret = malloc(num);\n#endif\n    return ret;\n}', 'DEFINE_LHASH_OF(ERR_STRING_DATA)', 'void CRYPTO_THREAD_lock_free(CRYPTO_RWLOCK *lock)\n{\n    if (lock == NULL)\n        return;\n# ifdef USE_RWLOCK\n    pthread_rwlock_destroy(lock);\n# else\n    pthread_mutex_destroy(lock);\n# endif\n    OPENSSL_free(lock);\n    return;\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#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}']