crypto/objects/o_names.c:132: error: NULL_DEREFERENCE
  pointer `name_funcs` last assigned on line 128 could be null and is dereferenced at line 132, column 9.
Showing all 71 steps of the trace


crypto/objects/o_names.c:82:1: start of procedure OBJ_NAME_new_index()
80.   }
81.   
82. > int OBJ_NAME_new_index(unsigned long (*hash_func) (const char *),
83.                          int (*cmp_func) (const char *, const char *),
84.                          void (*free_func) (const char *, int, const char *))

crypto/objects/o_names.c:86:5: 
84.                          void (*free_func) (const char *, int, const char *))
85.   {
86. >     int ret = 0, i, push;
87.       NAME_FUNCS *name_funcs;
88.   

crypto/objects/o_names.c:89:10: 
87.       NAME_FUNCS *name_funcs;
88.   
89. >     if (!OBJ_NAME_init())
90.           return 0;
91.   

crypto/objects/o_names.c:77:1: start of procedure OBJ_NAME_init()
  75.   }
  76.   
  77. > int OBJ_NAME_init(void)
  78.   {
  79.       return RUN_ONCE(&init, o_names_init);

crypto/objects/o_names.c:79:12: 
  77.   int OBJ_NAME_init(void)
  78.   {
  79. >     return RUN_ONCE(&init, o_names_init);
  80.   }
  81.   

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 false 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:110:5: 
    108.           return 0;
    109.   
    110. >     return 1;
    111.   }
    112.   

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/objects/o_names.c:79:12: Condition is true
  77.   int OBJ_NAME_init(void)
  78.   {
  79.       return RUN_ONCE(&init, o_names_init);
                   ^
  80.   }
  81.   

crypto/objects/o_names.c:79:5: 
  77.   int OBJ_NAME_init(void)
  78.   {
  79. >     return RUN_ONCE(&init, o_names_init);
  80.   }
  81.   

crypto/objects/o_names.c:80:1: return from a call to OBJ_NAME_init
  78.   {
  79.       return RUN_ONCE(&init, o_names_init);
  80. > }
  81.   
  82.   int OBJ_NAME_new_index(unsigned long (*hash_func) (const char *),

crypto/objects/o_names.c:89:10: Taking false branch
87.       NAME_FUNCS *name_funcs;
88.   
89.       if (!OBJ_NAME_init())
               ^
90.           return 0;
91.   

crypto/objects/o_names.c:92:5: 
90.           return 0;
91.   
92. >     CRYPTO_THREAD_write_lock(obj_lock);
93.   
94.       if (name_funcs_stack == NULL) {

crypto/threads_pthread.c:64:1: start of procedure CRYPTO_THREAD_write_lock()
  62.   }
  63.   
  64. > int CRYPTO_THREAD_write_lock(CRYPTO_RWLOCK *lock)
  65.   {
  66.   # ifdef USE_RWLOCK

crypto/threads_pthread.c:67:9: Taking true branch
  65.   {
  66.   # ifdef USE_RWLOCK
  67.       if (pthread_rwlock_wrlock(lock) != 0)
                ^
  68.           return 0;
  69.   # else

crypto/threads_pthread.c:68:9: 
  66.   # ifdef USE_RWLOCK
  67.       if (pthread_rwlock_wrlock(lock) != 0)
  68. >         return 0;
  69.   # else
  70.       if (pthread_mutex_lock(lock) != 0)

crypto/threads_pthread.c:75:1: return from a call to CRYPTO_THREAD_write_lock
  73.   
  74.       return 1;
  75. > }
  76.   
  77.   int CRYPTO_THREAD_unlock(CRYPTO_RWLOCK *lock)

crypto/objects/o_names.c:94:9: Taking true branch
92.       CRYPTO_THREAD_write_lock(obj_lock);
93.   
94.       if (name_funcs_stack == NULL) {
              ^
95.           CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_DISABLE);
96.           name_funcs_stack = sk_NAME_FUNCS_new_null();

crypto/objects/o_names.c:95:9: 
93.   
94.       if (name_funcs_stack == NULL) {
95. >         CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_DISABLE);
96.           name_funcs_stack = sk_NAME_FUNCS_new_null();
97.           CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ENABLE);

crypto/mem_dbg.c:117:1: start of procedure CRYPTO_mem_ctrl()
  115.   #endif
  116.   
  117. > int CRYPTO_mem_ctrl(int mode)
  118.   {
  119.   #ifdef OPENSSL_NO_CRYPTO_MDEBUG

crypto/mem_dbg.c:120:5: 
  118.   {
  119.   #ifdef OPENSSL_NO_CRYPTO_MDEBUG
  120. >     return mode - mode;
  121.   #else
  122.       int ret = mh_mode;

crypto/mem_dbg.c:188:1: return from a call to CRYPTO_mem_ctrl
  186.       return ret;
  187.   #endif
  188. > }
  189.   
  190.   #ifndef OPENSSL_NO_CRYPTO_MDEBUG

crypto/objects/o_names.c:96:9: 
94.       if (name_funcs_stack == NULL) {
95.           CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_DISABLE);
96. >         name_funcs_stack = sk_NAME_FUNCS_new_null();
97.           CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ENABLE);
98.       }

crypto/objects/obj_lcl.h:11:1: start of procedure sk_NAME_FUNCS_new_null()
  9.   
  10.   typedef struct name_funcs_st NAME_FUNCS;
  11. > DEFINE_STACK_OF(NAME_FUNCS)
  12.   DEFINE_LHASH_OF(OBJ_NAME);
  13.   typedef struct added_obj_st ADDED_OBJ;

crypto/stack/stack.c:112:1: start of procedure OPENSSL_sk_new_null()
    110.   }
    111.   
    112. > OPENSSL_STACK *OPENSSL_sk_new_null(void)
    113.   {
    114.       return OPENSSL_zalloc(sizeof(OPENSSL_STACK));

crypto/stack/stack.c:114:5: 
    112.   OPENSSL_STACK *OPENSSL_sk_new_null(void)
    113.   {
    114. >     return OPENSSL_zalloc(sizeof(OPENSSL_STACK));
    115.   }
    116.   

crypto/mem.c:198:1: start of procedure CRYPTO_zalloc()
      196.   }
      197.   
      198. > void *CRYPTO_zalloc(size_t num, const char *file, int line)
      199.   {
      200.       void *ret = CRYPTO_malloc(num, file, line);

crypto/mem.c:200:5: 
      198.   void *CRYPTO_zalloc(size_t num, const char *file, int line)
      199.   {
      200. >     void *ret = CRYPTO_malloc(num, file, line);
      201.   
      202.       FAILTEST();

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

crypto/mem.c:172:5: 
        170.   void *CRYPTO_malloc(size_t num, const char *file, int line)
        171.   {
        172. >     void *ret = NULL;
        173.   
        174.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)

crypto/mem.c:174:9: Taking false branch
        172.       void *ret = NULL;
        173.   
        174.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
                       ^
        175.           return malloc_impl(num, file, line);
        176.   

crypto/mem.c:177:9: Taking false branch
        175.           return malloc_impl(num, file, line);
        176.   
        177.       if (num == 0)
                       ^
        178.           return NULL;
        179.   

crypto/mem.c:181:5: 
        179.   
        180.       FAILTEST();
        181. >     allow_customize = 0;
        182.   #ifndef OPENSSL_NO_CRYPTO_MDEBUG
        183.       if (call_malloc_debug) {

crypto/mem.c:191:5: 
        189.       }
        190.   #else
        191. >     (void)(file); (void)(line);
        192.       ret = malloc(num);
        193.   #endif

crypto/mem.c:191:19: 
        189.       }
        190.   #else
        191. >     (void)(file); (void)(line);
        192.       ret = malloc(num);
        193.   #endif

crypto/mem.c:192:5: 
        190.   #else
        191.       (void)(file); (void)(line);
        192. >     ret = malloc(num);
        193.   #endif
        194.   

crypto/mem.c:195:5: 
        193.   #endif
        194.   
        195. >     return ret;
        196.   }
        197.   

crypto/mem.c:196:1: return from a call to CRYPTO_malloc
        194.   
        195.       return ret;
        196. > }
        197.   
        198.   void *CRYPTO_zalloc(size_t num, const char *file, int line)

crypto/mem.c:203:9: Taking true branch
      201.   
      202.       FAILTEST();
      203.       if (ret != NULL)
                     ^
      204.           memset(ret, 0, num);
      205.       return ret;

crypto/mem.c:204:9: 
      202.       FAILTEST();
      203.       if (ret != NULL)
      204. >         memset(ret, 0, num);
      205.       return ret;
      206.   }

crypto/mem.c:205:5: 
      203.       if (ret != NULL)
      204.           memset(ret, 0, num);
      205. >     return ret;
      206.   }
      207.   

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

crypto/stack/stack.c:115:1: return from a call to OPENSSL_sk_new_null
    113.   {
    114.       return OPENSSL_zalloc(sizeof(OPENSSL_STACK));
    115. > }
    116.   
    117.   OPENSSL_STACK *OPENSSL_sk_new(OPENSSL_sk_compfunc c)

crypto/objects/obj_lcl.h:11:1: return from a call to sk_NAME_FUNCS_new_null
  9.   
  10.   typedef struct name_funcs_st NAME_FUNCS;
  11. > DEFINE_STACK_OF(NAME_FUNCS)
  12.   DEFINE_LHASH_OF(OBJ_NAME);
  13.   typedef struct added_obj_st ADDED_OBJ;

crypto/objects/o_names.c:97:9: 
95.           CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_DISABLE);
96.           name_funcs_stack = sk_NAME_FUNCS_new_null();
97. >         CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ENABLE);
98.       }
99.       if (name_funcs_stack == NULL) {

crypto/mem_dbg.c:117:1: start of procedure CRYPTO_mem_ctrl()
  115.   #endif
  116.   
  117. > int CRYPTO_mem_ctrl(int mode)
  118.   {
  119.   #ifdef OPENSSL_NO_CRYPTO_MDEBUG

crypto/mem_dbg.c:120:5: 
  118.   {
  119.   #ifdef OPENSSL_NO_CRYPTO_MDEBUG
  120. >     return mode - mode;
  121.   #else
  122.       int ret = mh_mode;

crypto/mem_dbg.c:188:1: return from a call to CRYPTO_mem_ctrl
  186.       return ret;
  187.   #endif
  188. > }
  189.   
  190.   #ifndef OPENSSL_NO_CRYPTO_MDEBUG

crypto/objects/o_names.c:99:9: Taking false branch
97.           CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ENABLE);
98.       }
99.       if (name_funcs_stack == NULL) {
               ^
100.           /* ERROR */
101.           goto out;

crypto/objects/o_names.c:103:5: 
101.           goto out;
102.       }
103. >     ret = names_type_num;
104.       names_type_num++;
105.       for (i = sk_NAME_FUNCS_num(name_funcs_stack); i < names_type_num; i++) {

crypto/objects/o_names.c:104:5: 
102.       }
103.       ret = names_type_num;
104. >     names_type_num++;
105.       for (i = sk_NAME_FUNCS_num(name_funcs_stack); i < names_type_num; i++) {
106.           CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_DISABLE);

crypto/objects/o_names.c:105:10: 
103.       ret = names_type_num;
104.       names_type_num++;
105. >     for (i = sk_NAME_FUNCS_num(name_funcs_stack); i < names_type_num; i++) {
106.           CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_DISABLE);
107.           name_funcs = OPENSSL_zalloc(sizeof(*name_funcs));

crypto/objects/obj_lcl.h:11:1: start of procedure sk_NAME_FUNCS_num()
  9.   
  10.   typedef struct name_funcs_st NAME_FUNCS;
  11. > DEFINE_STACK_OF(NAME_FUNCS)
  12.   DEFINE_LHASH_OF(OBJ_NAME);
  13.   typedef struct added_obj_st ADDED_OBJ;

crypto/stack/stack.c:359:1: start of procedure OPENSSL_sk_num()
    357.   }
    358.   
    359. > int OPENSSL_sk_num(const OPENSSL_STACK *st)
    360.   {
    361.       return st == NULL ? -1 : st->num;

crypto/stack/stack.c:361:12: Condition is false
    359.   int OPENSSL_sk_num(const OPENSSL_STACK *st)
    360.   {
    361.       return st == NULL ? -1 : st->num;
                      ^
    362.   }
    363.   

crypto/stack/stack.c:361:5: 
    359.   int OPENSSL_sk_num(const OPENSSL_STACK *st)
    360.   {
    361. >     return st == NULL ? -1 : st->num;
    362.   }
    363.   

crypto/stack/stack.c:362:1: return from a call to OPENSSL_sk_num
    360.   {
    361.       return st == NULL ? -1 : st->num;
    362. > }
    363.   
    364.   void *OPENSSL_sk_value(const OPENSSL_STACK *st, int i)

crypto/objects/obj_lcl.h:11:1: return from a call to sk_NAME_FUNCS_num
  9.   
  10.   typedef struct name_funcs_st NAME_FUNCS;
  11. > DEFINE_STACK_OF(NAME_FUNCS)
  12.   DEFINE_LHASH_OF(OBJ_NAME);
  13.   typedef struct added_obj_st ADDED_OBJ;

crypto/objects/o_names.c:105:51: Loop condition is false. Leaving loop
103.       ret = names_type_num;
104.       names_type_num++;
105.       for (i = sk_NAME_FUNCS_num(name_funcs_stack); i < names_type_num; i++) {
                                                         ^
106.           CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_DISABLE);
107.           name_funcs = OPENSSL_zalloc(sizeof(*name_funcs));

crypto/objects/o_names.c:128:5: 
126.           }
127.       }
128. >     name_funcs = sk_NAME_FUNCS_value(name_funcs_stack, ret);
129.       if (hash_func != NULL)
130.           name_funcs->hash_func = hash_func;

crypto/objects/obj_lcl.h:11:1: start of procedure sk_NAME_FUNCS_value()
  9.   
  10.   typedef struct name_funcs_st NAME_FUNCS;
  11. > DEFINE_STACK_OF(NAME_FUNCS)
  12.   DEFINE_LHASH_OF(OBJ_NAME);
  13.   typedef struct added_obj_st ADDED_OBJ;

crypto/stack/stack.c:364:1: start of procedure OPENSSL_sk_value()
    362.   }
    363.   
    364. > void *OPENSSL_sk_value(const OPENSSL_STACK *st, int i)
    365.   {
    366.       if (st == NULL || i < 0 || i >= st->num)

crypto/stack/stack.c:366:9: Taking false branch
    364.   void *OPENSSL_sk_value(const OPENSSL_STACK *st, int i)
    365.   {
    366.       if (st == NULL || i < 0 || i >= st->num)
                   ^
    367.           return NULL;
    368.       return (void *)st->data[i];

crypto/stack/stack.c:366:23: Taking true branch
    364.   void *OPENSSL_sk_value(const OPENSSL_STACK *st, int i)
    365.   {
    366.       if (st == NULL || i < 0 || i >= st->num)
                                 ^
    367.           return NULL;
    368.       return (void *)st->data[i];

crypto/stack/stack.c:367:9: 
    365.   {
    366.       if (st == NULL || i < 0 || i >= st->num)
    367. >         return NULL;
    368.       return (void *)st->data[i];
    369.   }

crypto/stack/stack.c:369:1: return from a call to OPENSSL_sk_value
    367.           return NULL;
    368.       return (void *)st->data[i];
    369. > }
    370.   
    371.   void *OPENSSL_sk_set(OPENSSL_STACK *st, int i, const void *data)

crypto/objects/obj_lcl.h:11:1: return from a call to sk_NAME_FUNCS_value
  9.   
  10.   typedef struct name_funcs_st NAME_FUNCS;
  11. > DEFINE_STACK_OF(NAME_FUNCS)
  12.   DEFINE_LHASH_OF(OBJ_NAME);
  13.   typedef struct added_obj_st ADDED_OBJ;

crypto/objects/o_names.c:129:9: Taking false branch
127.       }
128.       name_funcs = sk_NAME_FUNCS_value(name_funcs_stack, ret);
129.       if (hash_func != NULL)
               ^
130.           name_funcs->hash_func = hash_func;
131.       if (cmp_func != NULL)

crypto/objects/o_names.c:131:9: Taking true branch
129.       if (hash_func != NULL)
130.           name_funcs->hash_func = hash_func;
131.       if (cmp_func != NULL)
               ^
132.           name_funcs->cmp_func = cmp_func;
133.       if (free_func != NULL)

crypto/objects/o_names.c:132:9: 
130.           name_funcs->hash_func = hash_func;
131.       if (cmp_func != NULL)
132. >         name_funcs->cmp_func = cmp_func;
133.       if (free_func != NULL)
134.           name_funcs->free_func = free_func;

int OBJ_NAME_new_index(unsigned long (*hash_func) (const char *),
                       int (*cmp_func) (const char *, const char *),
                       void (*free_func) (const char *, int, const char *))
{
    int ret = 0, i, push;
    NAME_FUNCS *name_funcs;
    if (!OBJ_NAME_init())
        return 0;
    CRYPTO_THREAD_write_lock(obj_lock);
    if (name_funcs_stack == NULL) {
        CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_DISABLE);
        name_funcs_stack = sk_NAME_FUNCS_new_null();
        CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ENABLE);
    }
    if (name_funcs_stack == NULL) {
        goto out;
    }
    ret = names_type_num;
    names_type_num++;
    for (i = sk_NAME_FUNCS_num(name_funcs_stack); i < names_type_num; i++) {
        CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_DISABLE);
        name_funcs = OPENSSL_zalloc(sizeof(*name_funcs));
        CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ENABLE);
        if (name_funcs == NULL) {
            OBJerr(OBJ_F_OBJ_NAME_NEW_INDEX, ERR_R_MALLOC_FAILURE);
            ret = 0;
            goto out;
        }
        name_funcs->hash_func = OPENSSL_LH_strhash;
        name_funcs->cmp_func = obj_strcmp;
        CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_DISABLE);
        push = sk_NAME_FUNCS_push(name_funcs_stack, name_funcs);
        CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ENABLE);
        if (!push) {
            OBJerr(OBJ_F_OBJ_NAME_NEW_INDEX, ERR_R_MALLOC_FAILURE);
            OPENSSL_free(name_funcs);
            ret = 0;
            goto out;
        }
    }
    name_funcs = sk_NAME_FUNCS_value(name_funcs_stack, ret);
    if (hash_func != NULL)
        name_funcs->hash_func = hash_func;
    if (cmp_func != NULL)
        name_funcs->cmp_func = cmp_func;
    if (free_func != NULL)
        name_funcs->free_func = free_func;
out:
    CRYPTO_THREAD_unlock(obj_lock);
    return ret;
}
['int OBJ_NAME_new_index(unsigned long (*hash_func) (const char *),\n                       int (*cmp_func) (const char *, const char *),\n                       void (*free_func) (const char *, int, const char *))\n{\n    int ret = 0, i, push;\n    NAME_FUNCS *name_funcs;\n    if (!OBJ_NAME_init())\n        return 0;\n    CRYPTO_THREAD_write_lock(obj_lock);\n    if (name_funcs_stack == NULL) {\n        CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_DISABLE);\n        name_funcs_stack = sk_NAME_FUNCS_new_null();\n        CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ENABLE);\n    }\n    if (name_funcs_stack == NULL) {\n        goto out;\n    }\n    ret = names_type_num;\n    names_type_num++;\n    for (i = sk_NAME_FUNCS_num(name_funcs_stack); i < names_type_num; i++) {\n        CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_DISABLE);\n        name_funcs = OPENSSL_zalloc(sizeof(*name_funcs));\n        CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ENABLE);\n        if (name_funcs == NULL) {\n            OBJerr(OBJ_F_OBJ_NAME_NEW_INDEX, ERR_R_MALLOC_FAILURE);\n            ret = 0;\n            goto out;\n        }\n        name_funcs->hash_func = OPENSSL_LH_strhash;\n        name_funcs->cmp_func = obj_strcmp;\n        CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_DISABLE);\n        push = sk_NAME_FUNCS_push(name_funcs_stack, name_funcs);\n        CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ENABLE);\n        if (!push) {\n            OBJerr(OBJ_F_OBJ_NAME_NEW_INDEX, ERR_R_MALLOC_FAILURE);\n            OPENSSL_free(name_funcs);\n            ret = 0;\n            goto out;\n        }\n    }\n    name_funcs = sk_NAME_FUNCS_value(name_funcs_stack, ret);\n    if (hash_func != NULL)\n        name_funcs->hash_func = hash_func;\n    if (cmp_func != NULL)\n        name_funcs->cmp_func = cmp_func;\n    if (free_func != NULL)\n        name_funcs->free_func = free_func;\nout:\n    CRYPTO_THREAD_unlock(obj_lock);\n    return ret;\n}', 'int OBJ_NAME_init(void)\n{\n    return RUN_ONCE(&init, o_names_init);\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}', 'int CRYPTO_THREAD_write_lock(CRYPTO_RWLOCK *lock)\n{\n# ifdef USE_RWLOCK\n    if (pthread_rwlock_wrlock(lock) != 0)\n        return 0;\n# else\n    if (pthread_mutex_lock(lock) != 0)\n        return 0;\n# endif\n    return 1;\n}', 'int CRYPTO_mem_ctrl(int mode)\n{\n#ifdef OPENSSL_NO_CRYPTO_MDEBUG\n    return mode - mode;\n#else\n    int ret = mh_mode;\n    if (!RUN_ONCE(&memdbg_init, do_memdbg_init))\n        return -1;\n    CRYPTO_THREAD_write_lock(malloc_lock);\n    switch (mode) {\n    default:\n        break;\n    case CRYPTO_MEM_CHECK_ON:\n        mh_mode = CRYPTO_MEM_CHECK_ON | CRYPTO_MEM_CHECK_ENABLE;\n        num_disable = 0;\n        break;\n    case CRYPTO_MEM_CHECK_OFF:\n        mh_mode = 0;\n        num_disable = 0;\n        break;\n    case CRYPTO_MEM_CHECK_DISABLE:\n        if (mh_mode & CRYPTO_MEM_CHECK_ON) {\n            CRYPTO_THREAD_ID cur = CRYPTO_THREAD_get_current_id();\n            if (!num_disable\n                || !CRYPTO_THREAD_compare_id(disabling_threadid, cur)) {\n                CRYPTO_THREAD_unlock(malloc_lock);\n                CRYPTO_THREAD_write_lock(long_malloc_lock);\n                CRYPTO_THREAD_write_lock(malloc_lock);\n                mh_mode &= ~CRYPTO_MEM_CHECK_ENABLE;\n                disabling_threadid = cur;\n            }\n            num_disable++;\n        }\n        break;\n    case CRYPTO_MEM_CHECK_ENABLE:\n        if (mh_mode & CRYPTO_MEM_CHECK_ON) {\n            if (num_disable) {\n                num_disable--;\n                if (num_disable == 0) {\n                    mh_mode |= CRYPTO_MEM_CHECK_ENABLE;\n                    CRYPTO_THREAD_unlock(long_malloc_lock);\n                }\n            }\n        }\n        break;\n    }\n    CRYPTO_THREAD_unlock(malloc_lock);\n    return ret;\n#endif\n}', 'OPENSSL_STACK *OPENSSL_sk_new_null(void)\n{\n    return OPENSSL_zalloc(sizeof(OPENSSL_STACK));\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    (void)(file); (void)(line);\n    ret = malloc(num);\n#endif\n    return ret;\n}', 'int OPENSSL_sk_num(const OPENSSL_STACK *st)\n{\n    return st == NULL ? -1 : st->num;\n}', 'void *OPENSSL_sk_value(const OPENSSL_STACK *st, int i)\n{\n    if (st == NULL || i < 0 || i >= st->num)\n        return NULL;\n    return (void *)st->data[i];\n}']