crypto/rand/md_rand.c:523: error: MEMORY_LEAK
  memory dynamically allocated by call to `EVP_MD_CTX_new()` at line 326, column 9 is not reachable after line 523, column 5.
Showing all 49 steps of the trace


crypto/rand/md_rand.c:278:1: start of procedure rand_bytes()
276.   }
277.   
278. > static int rand_bytes(unsigned char *buf, int num, int pseudo)
279.   {
280.       static volatile int stirred_pool = 0;

crypto/rand/md_rand.c:280:5: 
278.   static int rand_bytes(unsigned char *buf, int num, int pseudo)
279.   {
280. >     static volatile int stirred_pool = 0;
281.       int i, j, k;
282.       size_t num_ceil, st_idx, st_num;

crypto/rand/md_rand.c:288:5: 
286.       EVP_MD_CTX *m;
287.   #ifndef GETPID_IS_MEANINGLESS
288. >     pid_t curr_pid = getpid();
289.   #endif
290.       time_t curr_time = time(NULL);

crypto/rand/md_rand.c:290:5: 
288.       pid_t curr_pid = getpid();
289.   #endif
290. >     time_t curr_time = time(NULL);
291.       int do_stir_pool = 0;
292.   /* time value for various platforms */

crypto/rand/md_rand.c:291:5: 
289.   #endif
290.       time_t curr_time = time(NULL);
291. >     int do_stir_pool = 0;
292.   /* time value for various platforms */
293.   #ifdef OPENSSL_SYS_WIN32

crypto/rand/md_rand.c:310:5: 
308.   #else
309.       struct timeval tv;
310. >     gettimeofday(&tv, NULL);
311.   #endif
312.   

crypto/rand/md_rand.c:323:9: Taking false branch
321.   #endif
322.   
323.       if (num <= 0)
               ^
324.           return 1;
325.   

crypto/rand/md_rand.c:326:5: 
324.           return 1;
325.   
326. >     m = EVP_MD_CTX_new();
327.       if (m == NULL)
328.           goto err_mem;

crypto/evp/digest.c:44:1: start of procedure EVP_MD_CTX_new()
  42.   }
  43.   
  44. > EVP_MD_CTX *EVP_MD_CTX_new(void)
  45.   {
  46.       return OPENSSL_zalloc(sizeof(EVP_MD_CTX));

crypto/evp/digest.c:46:5: 
  44.   EVP_MD_CTX *EVP_MD_CTX_new(void)
  45.   {
  46. >     return OPENSSL_zalloc(sizeof(EVP_MD_CTX));
  47.   }
  48.   

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/evp/digest.c:47:1: return from a call to EVP_MD_CTX_new
  45.   {
  46.       return OPENSSL_zalloc(sizeof(EVP_MD_CTX));
  47. > }
  48.   
  49.   void EVP_MD_CTX_free(EVP_MD_CTX *ctx)

crypto/rand/md_rand.c:327:9: Taking false branch
325.   
326.       m = EVP_MD_CTX_new();
327.       if (m == NULL)
               ^
328.           goto err_mem;
329.   

crypto/rand/md_rand.c:331:5: 
329.   
330.       /* round upwards to multiple of MD_DIGEST_LENGTH/2 */
331. >     num_ceil =
332.           (1 + (num - 1) / (MD_DIGEST_LENGTH / 2)) * (MD_DIGEST_LENGTH / 2);
333.   

crypto/rand/md_rand.c:352:10: 
350.        */
351.   
352. >     if (!RUN_ONCE(&rand_lock_init, do_rand_lock_init))
353.           goto err_mem;
354.   

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 false 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:68:5: 
  66.           return 0;
  67.   
  68. >     return 1;
  69.   }
  70.   

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/rand/md_rand.c:352:10: Condition is true
350.        */
351.   
352.       if (!RUN_ONCE(&rand_lock_init, do_rand_lock_init))
                ^
353.           goto err_mem;
354.   

crypto/rand/md_rand.c:352:10: Taking true branch
350.        */
351.   
352.       if (!RUN_ONCE(&rand_lock_init, do_rand_lock_init))
                ^
353.           goto err_mem;
354.   

crypto/rand/md_rand.c:521:2: 
519.       EVP_MD_CTX_free(m);
520.       return 0;
521. >  err_mem:
522.       RANDerr(RAND_F_RAND_BYTES, ERR_R_MALLOC_FAILURE);
523.       EVP_MD_CTX_free(m);

crypto/rand/md_rand.c:522:5: Skipping ERR_put_error(): empty list of specs
520.       return 0;
521.    err_mem:
522.       RANDerr(RAND_F_RAND_BYTES, ERR_R_MALLOC_FAILURE);
           ^
523.       EVP_MD_CTX_free(m);
524.       return 0;

crypto/rand/md_rand.c:523:5: 
521.    err_mem:
522.       RANDerr(RAND_F_RAND_BYTES, ERR_R_MALLOC_FAILURE);
523. >     EVP_MD_CTX_free(m);
524.       return 0;
525.   

crypto/evp/digest.c:49:1: start of procedure EVP_MD_CTX_free()
  47.   }
  48.   
  49. > void EVP_MD_CTX_free(EVP_MD_CTX *ctx)
  50.   {
  51.       EVP_MD_CTX_reset(ctx);

crypto/evp/digest.c:51:5: Skipping EVP_MD_CTX_reset(): empty list of specs
  49.   void EVP_MD_CTX_free(EVP_MD_CTX *ctx)
  50.   {
  51.       EVP_MD_CTX_reset(ctx);
            ^
  52.       OPENSSL_free(ctx);
  53.   }

crypto/evp/digest.c:52:5: 
  50.   {
  51.       EVP_MD_CTX_reset(ctx);
  52. >     OPENSSL_free(ctx);
  53.   }
  54.   

crypto/mem.c:163:1: start of procedure CRYPTO_free()
    161.   }
    162.   
    163. > void CRYPTO_free(void *str, const char *file, int line)
    164.   {
    165.       if (free_impl != NULL && free_impl != &CRYPTO_free) {

crypto/mem.c:165:9: Taking true branch
    163.   void CRYPTO_free(void *str, const char *file, int line)
    164.   {
    165.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
                   ^
    166.           free_impl(str, file, line);
    167.           return;

crypto/mem.c:165:30: Taking true branch
    163.   void CRYPTO_free(void *str, const char *file, int line)
    164.   {
    165.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
                                        ^
    166.           free_impl(str, file, line);
    167.           return;

crypto/mem.c:166:9: Skipping __function_pointer__(): unresolved function pointer
    164.   {
    165.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
    166.           free_impl(str, file, line);
                   ^
    167.           return;
    168.       }

crypto/mem.c:167:9: 
    165.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
    166.           free_impl(str, file, line);
    167. >         return;
    168.       }
    169.   

crypto/mem.c:181:1: return from a call to CRYPTO_free
    179.       free(str);
    180.   #endif
    181. > }
    182.   
    183.   void CRYPTO_clear_free(void *str, size_t num, const char *file, int line)

crypto/evp/digest.c:53:1: return from a call to EVP_MD_CTX_free
  51.       EVP_MD_CTX_reset(ctx);
  52.       OPENSSL_free(ctx);
  53. > }
  54.   
  55.   int EVP_DigestInit(EVP_MD_CTX *ctx, const EVP_MD *type)

static int rand_bytes(unsigned char *buf, int num, int pseudo)
{
    static volatile int stirred_pool = 0;
    int i, j, k;
    size_t num_ceil, st_idx, st_num;
    int ok;
    long md_c[2];
    unsigned char local_md[MD_DIGEST_LENGTH];
    EVP_MD_CTX *m;
#ifndef GETPID_IS_MEANINGLESS
    pid_t curr_pid = getpid();
#endif
    time_t curr_time = time(NULL);
    int do_stir_pool = 0;
#ifdef OPENSSL_SYS_WIN32
    FILETIME tv;
# ifdef _WIN32_WCE
    SYSTEMTIME t;
    GetSystemTime(&t);
    SystemTimeToFileTime(&t, &tv);
# else
    GetSystemTimeAsFileTime(&tv);
# endif
#elif defined(OPENSSL_SYS_VXWORKS)
    struct timespec tv;
    clock_gettime(CLOCK_REALTIME, &ts);
#elif defined(OPENSSL_SYS_DSPBIOS)
    unsigned long long tv, OPENSSL_rdtsc();
    tv = OPENSSL_rdtsc();
#else
    struct timeval tv;
    gettimeofday(&tv, NULL);
#endif
#ifdef PREDICT
    if (rand_predictable) {
        unsigned char val = 1;
        for (i = 0; i < num; i++)
            buf[i] = val++;
        return (1);
    }
#endif
    if (num <= 0)
        return 1;
    m = EVP_MD_CTX_new();
    if (m == NULL)
        goto err_mem;
    num_ceil =
        (1 + (num - 1) / (MD_DIGEST_LENGTH / 2)) * (MD_DIGEST_LENGTH / 2);
    if (!RUN_ONCE(&rand_lock_init, do_rand_lock_init))
        goto err_mem;
    CRYPTO_THREAD_write_lock(rand_lock);
    ASYNC_block_pause();
    CRYPTO_THREAD_write_lock(rand_tmp_lock);
    locking_threadid = CRYPTO_THREAD_get_current_id();
    CRYPTO_THREAD_unlock(rand_tmp_lock);
    crypto_lock_rand = 1;
    if (!initialized) {
        RAND_poll();
        initialized = 1;
    }
    if (!stirred_pool)
        do_stir_pool = 1;
    ok = (entropy >= ENTROPY_NEEDED);
    if (!ok) {
        entropy -= num;
        if (entropy < 0)
            entropy = 0;
    }
    if (do_stir_pool) {
        int n = STATE_SIZE;
        while (n > 0) {
#if MD_DIGEST_LENGTH > 20
# error "Please adjust DUMMY_SEED."
#endif
#define DUMMY_SEED "...................."
            rand_add(DUMMY_SEED, MD_DIGEST_LENGTH, 0.0);
            n -= MD_DIGEST_LENGTH;
        }
        if (ok)
            stirred_pool = 1;
    }
    st_idx = state_index;
    st_num = state_num;
    md_c[0] = md_count[0];
    md_c[1] = md_count[1];
    memcpy(local_md, md, sizeof md);
    state_index += num_ceil;
    if (state_index > state_num)
        state_index %= state_num;
    md_count[0] += 1;
    crypto_lock_rand = 0;
    ASYNC_unblock_pause();
    CRYPTO_THREAD_unlock(rand_lock);
    while (num > 0) {
        j = (num >= MD_DIGEST_LENGTH / 2) ? MD_DIGEST_LENGTH / 2 : num;
        num -= j;
        if (!MD_Init(m))
            goto err;
#ifndef GETPID_IS_MEANINGLESS
        if (curr_pid) {
            if (!MD_Update(m, (unsigned char *)&curr_pid, sizeof curr_pid))
                goto err;
            curr_pid = 0;
        }
#endif
        if (curr_time) {
            if (!MD_Update(m, (unsigned char *)&curr_time, sizeof curr_time))
                goto err;
            if (!MD_Update(m, (unsigned char *)&tv, sizeof tv))
                goto err;
            curr_time = 0;
            if (!rand_hw_seed(m))
                goto err;
        }
        if (!MD_Update(m, local_md, MD_DIGEST_LENGTH))
            goto err;
        if (!MD_Update(m, (unsigned char *)&(md_c[0]), sizeof(md_c)))
            goto err;
        k = (st_idx + MD_DIGEST_LENGTH / 2) - st_num;
        if (k > 0) {
            if (!MD_Update(m, &(state[st_idx]), MD_DIGEST_LENGTH / 2 - k))
                goto err;
            if (!MD_Update(m, &(state[0]), k))
                goto err;
        } else if (!MD_Update(m, &(state[st_idx]), MD_DIGEST_LENGTH / 2))
            goto err;
        if (!MD_Final(m, local_md))
            goto err;
        for (i = 0; i < MD_DIGEST_LENGTH / 2; i++) {
            state[st_idx++] ^= local_md[i];
            if (st_idx >= st_num)
                st_idx = 0;
            if (i < j)
                *(buf++) = local_md[i + MD_DIGEST_LENGTH / 2];
        }
    }
    if (!MD_Init(m)
        || !MD_Update(m, (unsigned char *)&(md_c[0]), sizeof(md_c))
        || !MD_Update(m, local_md, MD_DIGEST_LENGTH))
        goto err;
    CRYPTO_THREAD_write_lock(rand_lock);
    ASYNC_block_pause();
    if (!MD_Update(m, md, MD_DIGEST_LENGTH) || !MD_Final(m, md)) {
        CRYPTO_THREAD_unlock(rand_lock);
        goto err;
    }
    ASYNC_unblock_pause();
    CRYPTO_THREAD_unlock(rand_lock);
    EVP_MD_CTX_free(m);
    if (ok)
        return (1);
    else if (pseudo)
        return 0;
    else {
        RANDerr(RAND_F_RAND_BYTES, RAND_R_PRNG_NOT_SEEDED);
        ERR_add_error_data(1, "You need to read the OpenSSL FAQ, "
                           "https://www.openssl.org/docs/faq.html");
        return (0);
    }
 err:
    RANDerr(RAND_F_RAND_BYTES, ERR_R_EVP_LIB);
    EVP_MD_CTX_free(m);
    return 0;
 err_mem:
    RANDerr(RAND_F_RAND_BYTES, ERR_R_MALLOC_FAILURE);
    EVP_MD_CTX_free(m);
    return 0;
}
['static int rand_bytes(unsigned char *buf, int num, int pseudo)\n{\n    static volatile int stirred_pool = 0;\n    int i, j, k;\n    size_t num_ceil, st_idx, st_num;\n    int ok;\n    long md_c[2];\n    unsigned char local_md[MD_DIGEST_LENGTH];\n    EVP_MD_CTX *m;\n#ifndef GETPID_IS_MEANINGLESS\n    pid_t curr_pid = getpid();\n#endif\n    time_t curr_time = time(NULL);\n    int do_stir_pool = 0;\n#ifdef OPENSSL_SYS_WIN32\n    FILETIME tv;\n# ifdef _WIN32_WCE\n    SYSTEMTIME t;\n    GetSystemTime(&t);\n    SystemTimeToFileTime(&t, &tv);\n# else\n    GetSystemTimeAsFileTime(&tv);\n# endif\n#elif defined(OPENSSL_SYS_VXWORKS)\n    struct timespec tv;\n    clock_gettime(CLOCK_REALTIME, &ts);\n#elif defined(OPENSSL_SYS_DSPBIOS)\n    unsigned long long tv, OPENSSL_rdtsc();\n    tv = OPENSSL_rdtsc();\n#else\n    struct timeval tv;\n    gettimeofday(&tv, NULL);\n#endif\n#ifdef PREDICT\n    if (rand_predictable) {\n        unsigned char val = 1;\n        for (i = 0; i < num; i++)\n            buf[i] = val++;\n        return (1);\n    }\n#endif\n    if (num <= 0)\n        return 1;\n    m = EVP_MD_CTX_new();\n    if (m == NULL)\n        goto err_mem;\n    num_ceil =\n        (1 + (num - 1) / (MD_DIGEST_LENGTH / 2)) * (MD_DIGEST_LENGTH / 2);\n    if (!RUN_ONCE(&rand_lock_init, do_rand_lock_init))\n        goto err_mem;\n    CRYPTO_THREAD_write_lock(rand_lock);\n    ASYNC_block_pause();\n    CRYPTO_THREAD_write_lock(rand_tmp_lock);\n    locking_threadid = CRYPTO_THREAD_get_current_id();\n    CRYPTO_THREAD_unlock(rand_tmp_lock);\n    crypto_lock_rand = 1;\n    if (!initialized) {\n        RAND_poll();\n        initialized = 1;\n    }\n    if (!stirred_pool)\n        do_stir_pool = 1;\n    ok = (entropy >= ENTROPY_NEEDED);\n    if (!ok) {\n        entropy -= num;\n        if (entropy < 0)\n            entropy = 0;\n    }\n    if (do_stir_pool) {\n        int n = STATE_SIZE;\n        while (n > 0) {\n#if MD_DIGEST_LENGTH > 20\n# error "Please adjust DUMMY_SEED."\n#endif\n#define DUMMY_SEED "...................."\n            rand_add(DUMMY_SEED, MD_DIGEST_LENGTH, 0.0);\n            n -= MD_DIGEST_LENGTH;\n        }\n        if (ok)\n            stirred_pool = 1;\n    }\n    st_idx = state_index;\n    st_num = state_num;\n    md_c[0] = md_count[0];\n    md_c[1] = md_count[1];\n    memcpy(local_md, md, sizeof md);\n    state_index += num_ceil;\n    if (state_index > state_num)\n        state_index %= state_num;\n    md_count[0] += 1;\n    crypto_lock_rand = 0;\n    ASYNC_unblock_pause();\n    CRYPTO_THREAD_unlock(rand_lock);\n    while (num > 0) {\n        j = (num >= MD_DIGEST_LENGTH / 2) ? MD_DIGEST_LENGTH / 2 : num;\n        num -= j;\n        if (!MD_Init(m))\n            goto err;\n#ifndef GETPID_IS_MEANINGLESS\n        if (curr_pid) {\n            if (!MD_Update(m, (unsigned char *)&curr_pid, sizeof curr_pid))\n                goto err;\n            curr_pid = 0;\n        }\n#endif\n        if (curr_time) {\n            if (!MD_Update(m, (unsigned char *)&curr_time, sizeof curr_time))\n                goto err;\n            if (!MD_Update(m, (unsigned char *)&tv, sizeof tv))\n                goto err;\n            curr_time = 0;\n            if (!rand_hw_seed(m))\n                goto err;\n        }\n        if (!MD_Update(m, local_md, MD_DIGEST_LENGTH))\n            goto err;\n        if (!MD_Update(m, (unsigned char *)&(md_c[0]), sizeof(md_c)))\n            goto err;\n        k = (st_idx + MD_DIGEST_LENGTH / 2) - st_num;\n        if (k > 0) {\n            if (!MD_Update(m, &(state[st_idx]), MD_DIGEST_LENGTH / 2 - k))\n                goto err;\n            if (!MD_Update(m, &(state[0]), k))\n                goto err;\n        } else if (!MD_Update(m, &(state[st_idx]), MD_DIGEST_LENGTH / 2))\n            goto err;\n        if (!MD_Final(m, local_md))\n            goto err;\n        for (i = 0; i < MD_DIGEST_LENGTH / 2; i++) {\n            state[st_idx++] ^= local_md[i];\n            if (st_idx >= st_num)\n                st_idx = 0;\n            if (i < j)\n                *(buf++) = local_md[i + MD_DIGEST_LENGTH / 2];\n        }\n    }\n    if (!MD_Init(m)\n        || !MD_Update(m, (unsigned char *)&(md_c[0]), sizeof(md_c))\n        || !MD_Update(m, local_md, MD_DIGEST_LENGTH))\n        goto err;\n    CRYPTO_THREAD_write_lock(rand_lock);\n    ASYNC_block_pause();\n    if (!MD_Update(m, md, MD_DIGEST_LENGTH) || !MD_Final(m, md)) {\n        CRYPTO_THREAD_unlock(rand_lock);\n        goto err;\n    }\n    ASYNC_unblock_pause();\n    CRYPTO_THREAD_unlock(rand_lock);\n    EVP_MD_CTX_free(m);\n    if (ok)\n        return (1);\n    else if (pseudo)\n        return 0;\n    else {\n        RANDerr(RAND_F_RAND_BYTES, RAND_R_PRNG_NOT_SEEDED);\n        ERR_add_error_data(1, "You need to read the OpenSSL FAQ, "\n                           "https://www.openssl.org/docs/faq.html");\n        return (0);\n    }\n err:\n    RANDerr(RAND_F_RAND_BYTES, ERR_R_EVP_LIB);\n    EVP_MD_CTX_free(m);\n    return 0;\n err_mem:\n    RANDerr(RAND_F_RAND_BYTES, ERR_R_MALLOC_FAILURE);\n    EVP_MD_CTX_free(m);\n    return 0;\n}', 'EVP_MD_CTX *EVP_MD_CTX_new(void)\n{\n    return OPENSSL_zalloc(sizeof(EVP_MD_CTX));\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}', '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 EVP_MD_CTX_free(EVP_MD_CTX *ctx)\n{\n    EVP_MD_CTX_reset(ctx);\n    OPENSSL_free(ctx);\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}']