test/threadstest.c:89: error: MEMORY_LEAK
  memory dynamically allocated by call to `CRYPTO_THREAD_lock_new()` at line 86, column 27 is not reachable after line 89, column 17.
Showing all 31 steps of the trace


test/threadstest.c:84:1: start of procedure test_lock()
82.   #endif
83.   
84. > static int test_lock(void)
85.   {
86.       CRYPTO_RWLOCK *lock = CRYPTO_THREAD_lock_new();

test/threadstest.c:86:5: 
84.   static int test_lock(void)
85.   {
86. >     CRYPTO_RWLOCK *lock = CRYPTO_THREAD_lock_new();
87.   
88.       if (!CRYPTO_THREAD_read_lock(lock)) {

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:185:1: start of procedure CRYPTO_zalloc()
    183.   }
    184.   
    185. > void *CRYPTO_zalloc(size_t num, const char *file, int line)
    186.   {
    187.       void *ret = CRYPTO_malloc(num, file, line);

crypto/mem.c:187:5: 
    185.   void *CRYPTO_zalloc(size_t num, const char *file, int line)
    186.   {
    187. >     void *ret = CRYPTO_malloc(num, file, line);
    188.   
    189.       FAILTEST();

crypto/mem.c:157:1: start of procedure CRYPTO_malloc()
      155.   #endif
      156.   
      157. > void *CRYPTO_malloc(size_t num, const char *file, int line)
      158.   {
      159.       void *ret = NULL;

crypto/mem.c:159:5: 
      157.   void *CRYPTO_malloc(size_t num, const char *file, int line)
      158.   {
      159. >     void *ret = NULL;
      160.   
      161.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)

crypto/mem.c:161:9: Taking false branch
      159.       void *ret = NULL;
      160.   
      161.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
                     ^
      162.           return malloc_impl(num, file, line);
      163.   

crypto/mem.c:164:9: Taking false branch
      162.           return malloc_impl(num, file, line);
      163.   
      164.       if (num <= 0)
                     ^
      165.           return NULL;
      166.   

crypto/mem.c:168:5: 
      166.   
      167.       FAILTEST();
      168. >     allow_customize = 0;
      169.   #ifndef OPENSSL_NO_CRYPTO_MDEBUG
      170.       if (call_malloc_debug) {

crypto/mem.c:178:5: 
      176.       }
      177.   #else
      178. >     osslargused(file); osslargused(line);
      179.       ret = malloc(num);
      180.   #endif

crypto/mem.c:178:24: 
      176.       }
      177.   #else
      178. >     osslargused(file); osslargused(line);
      179.       ret = malloc(num);
      180.   #endif

crypto/mem.c:179:5: 
      177.   #else
      178.       osslargused(file); osslargused(line);
      179. >     ret = malloc(num);
      180.   #endif
      181.   

crypto/mem.c:182:5: 
      180.   #endif
      181.   
      182. >     return ret;
      183.   }
      184.   

crypto/mem.c:183:1: return from a call to CRYPTO_malloc
      181.   
      182.       return ret;
      183. > }
      184.   
      185.   void *CRYPTO_zalloc(size_t num, const char *file, int line)

crypto/mem.c:190:9: Taking true branch
    188.   
    189.       FAILTEST();
    190.       if (ret != NULL)
                   ^
    191.           memset(ret, 0, num);
    192.       return ret;

crypto/mem.c:191:9: 
    189.       FAILTEST();
    190.       if (ret != NULL)
    191. >         memset(ret, 0, num);
    192.       return ret;
    193.   }

crypto/mem.c:192:5: 
    190.       if (ret != NULL)
    191.           memset(ret, 0, num);
    192. >     return ret;
    193.   }
    194.   

crypto/mem.c:193:1: return from a call to CRYPTO_zalloc
    191.           memset(ret, 0, num);
    192.       return ret;
    193. > }
    194.   
    195.   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)

test/threadstest.c:88:10: 
86.       CRYPTO_RWLOCK *lock = CRYPTO_THREAD_lock_new();
87.   
88. >     if (!CRYPTO_THREAD_read_lock(lock)) {
89.           fprintf(stderr, "CRYPTO_THREAD_read_lock() failed\n");
90.           return 0;

crypto/threads_pthread.c:28:1: start of procedure CRYPTO_THREAD_read_lock()
  26.   }
  27.   
  28. > int CRYPTO_THREAD_read_lock(CRYPTO_RWLOCK *lock)
  29.   {
  30.       if (pthread_rwlock_rdlock(lock) != 0)

crypto/threads_pthread.c:30:9: Taking true branch
  28.   int CRYPTO_THREAD_read_lock(CRYPTO_RWLOCK *lock)
  29.   {
  30.       if (pthread_rwlock_rdlock(lock) != 0)
                ^
  31.           return 0;
  32.   

crypto/threads_pthread.c:31:9: 
  29.   {
  30.       if (pthread_rwlock_rdlock(lock) != 0)
  31. >         return 0;
  32.   
  33.       return 1;

crypto/threads_pthread.c:34:1: return from a call to CRYPTO_THREAD_read_lock
  32.   
  33.       return 1;
  34. > }
  35.   
  36.   int CRYPTO_THREAD_write_lock(CRYPTO_RWLOCK *lock)

test/threadstest.c:88:10: Taking true branch
86.       CRYPTO_RWLOCK *lock = CRYPTO_THREAD_lock_new();
87.   
88.       if (!CRYPTO_THREAD_read_lock(lock)) {
               ^
89.           fprintf(stderr, "CRYPTO_THREAD_read_lock() failed\n");
90.           return 0;

test/threadstest.c:89:9: 
87.   
88.       if (!CRYPTO_THREAD_read_lock(lock)) {
89. >         fprintf(stderr, "CRYPTO_THREAD_read_lock() failed\n");
90.           return 0;
91.       }

static int test_lock(void)
{
    CRYPTO_RWLOCK *lock = CRYPTO_THREAD_lock_new();
    if (!CRYPTO_THREAD_read_lock(lock)) {
        fprintf(stderr, "CRYPTO_THREAD_read_lock() failed\n");
        return 0;
    }
    if (!CRYPTO_THREAD_unlock(lock)) {
        fprintf(stderr, "CRYPTO_THREAD_unlock() failed\n");
        return 0;
    }
    CRYPTO_THREAD_lock_free(lock);
    return 1;
}
['static int test_lock(void)\n{\n    CRYPTO_RWLOCK *lock = CRYPTO_THREAD_lock_new();\n    if (!CRYPTO_THREAD_read_lock(lock)) {\n        fprintf(stderr, "CRYPTO_THREAD_read_lock() failed\\n");\n        return 0;\n    }\n    if (!CRYPTO_THREAD_unlock(lock)) {\n        fprintf(stderr, "CRYPTO_THREAD_unlock() failed\\n");\n        return 0;\n    }\n    CRYPTO_THREAD_lock_free(lock);\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    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}', 'int CRYPTO_THREAD_read_lock(CRYPTO_RWLOCK *lock)\n{\n    if (pthread_rwlock_rdlock(lock) != 0)\n        return 0;\n    return 1;\n}']