crypto/objects/o_names.c:236: error: MEMORY_LEAK
  memory dynamically allocated by call to `CRYPTO_malloc()` at line 222, column 11 is not reachable after line 236, column 14.
Showing all 51 steps of the trace


crypto/objects/o_names.c:209:1: start of procedure OBJ_NAME_add()
207.   }
208.   
209. > int OBJ_NAME_add(const char *name, int type, const char *data)
210.   {
211.       OBJ_NAME *onp, *ret;

crypto/objects/o_names.c:212:5: 
210.   {
211.       OBJ_NAME *onp, *ret;
212. >     int alias, ok = 0;
213.   
214.       if (!OBJ_NAME_init())

crypto/objects/o_names.c:214:10: 
212.       int alias, ok = 0;
213.   
214. >     if (!OBJ_NAME_init())
215.           return 0;
216.   

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:214:10: Taking false branch
212.       int alias, ok = 0;
213.   
214.       if (!OBJ_NAME_init())
                ^
215.           return 0;
216.   

crypto/objects/o_names.c:217:5: 
215.           return 0;
216.   
217. >     CRYPTO_THREAD_write_lock(obj_lock);
218.   
219.       alias = type & OBJ_NAME_ALIAS;

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:219:5: 
217.       CRYPTO_THREAD_write_lock(obj_lock);
218.   
219. >     alias = type & OBJ_NAME_ALIAS;
220.       type &= ~OBJ_NAME_ALIAS;
221.   

crypto/objects/o_names.c:220:5: 
218.   
219.       alias = type & OBJ_NAME_ALIAS;
220. >     type &= ~OBJ_NAME_ALIAS;
221.   
222.       onp = OPENSSL_malloc(sizeof(*onp));

crypto/objects/o_names.c:222:5: 
220.       type &= ~OBJ_NAME_ALIAS;
221.   
222. >     onp = OPENSSL_malloc(sizeof(*onp));
223.       if (onp == NULL) {
224.           /* ERROR */

crypto/mem.c:189:1: start of procedure CRYPTO_malloc()
  187.   #endif
  188.   
  189. > void *CRYPTO_malloc(size_t num, const char *file, int line)
  190.   {
  191.       void *ret = NULL;

crypto/mem.c:191:5: 
  189.   void *CRYPTO_malloc(size_t num, const char *file, int line)
  190.   {
  191. >     void *ret = NULL;
  192.   
  193.       INCREMENT(malloc_count);

crypto/mem.c:194:9: Taking false branch
  192.   
  193.       INCREMENT(malloc_count);
  194.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
                 ^
  195.           return malloc_impl(num, file, line);
  196.   

crypto/mem.c:197:9: Taking false branch
  195.           return malloc_impl(num, file, line);
  196.   
  197.       if (num == 0)
                 ^
  198.           return NULL;
  199.   

crypto/mem.c:201:5: 
  199.   
  200.       FAILTEST();
  201. >     allow_customize = 0;
  202.   #ifndef OPENSSL_NO_CRYPTO_MDEBUG
  203.       if (call_malloc_debug) {

crypto/mem.c:211:5: 
  209.       }
  210.   #else
  211. >     (void)(file); (void)(line);
  212.       ret = malloc(num);
  213.   #endif

crypto/mem.c:211:19: 
  209.       }
  210.   #else
  211. >     (void)(file); (void)(line);
  212.       ret = malloc(num);
  213.   #endif

crypto/mem.c:212:5: 
  210.   #else
  211.       (void)(file); (void)(line);
  212. >     ret = malloc(num);
  213.   #endif
  214.   

crypto/mem.c:215:5: 
  213.   #endif
  214.   
  215. >     return ret;
  216.   }
  217.   

crypto/mem.c:216:1: return from a call to CRYPTO_malloc
  214.   
  215.       return ret;
  216. > }
  217.   
  218.   void *CRYPTO_zalloc(size_t num, const char *file, int line)

crypto/objects/o_names.c:223:9: Taking false branch
221.   
222.       onp = OPENSSL_malloc(sizeof(*onp));
223.       if (onp == NULL) {
               ^
224.           /* ERROR */
225.           goto unlock;

crypto/objects/o_names.c:228:5: 
226.       }
227.   
228. >     onp->name = name;
229.       onp->alias = alias;
230.       onp->type = type;

crypto/objects/o_names.c:229:5: 
227.   
228.       onp->name = name;
229. >     onp->alias = alias;
230.       onp->type = type;
231.       onp->data = data;

crypto/objects/o_names.c:230:5: 
228.       onp->name = name;
229.       onp->alias = alias;
230. >     onp->type = type;
231.       onp->data = data;
232.   

crypto/objects/o_names.c:231:5: 
229.       onp->alias = alias;
230.       onp->type = type;
231. >     onp->data = data;
232.   
233.       ret = lh_OBJ_NAME_insert(names_lh, onp);

crypto/objects/o_names.c:233:5: 
231.       onp->data = data;
232.   
233. >     ret = lh_OBJ_NAME_insert(names_lh, onp);
234.       if (ret != NULL) {
235.           /* free things */

crypto/objects/obj_lcl.h:12:1: start of procedure lh_OBJ_NAME_insert()
  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;
  14.   DEFINE_LHASH_OF(ADDED_OBJ);

crypto/lhash/lhash.c:87:1: start of procedure OPENSSL_LH_insert()
    85.   }
    86.   
    87. > void *OPENSSL_LH_insert(OPENSSL_LHASH *lh, void *data)
    88.   {
    89.       unsigned long hash;

crypto/lhash/lhash.c:93:5: 
    91.       void *ret;
    92.   
    93. >     lh->error = 0;
    94.       if ((lh->up_load <= (lh->num_items * LH_LOAD_MULT / lh->num_nodes)) && !expand(lh))
    95.           return NULL;        /* 'lh->error++' already done in 'expand' */

crypto/lhash/lhash.c:94:10: Taking false branch
    92.   
    93.       lh->error = 0;
    94.       if ((lh->up_load <= (lh->num_items * LH_LOAD_MULT / lh->num_nodes)) && !expand(lh))
                   ^
    95.           return NULL;        /* 'lh->error++' already done in 'expand' */
    96.   

crypto/lhash/lhash.c:97:5: Skipping getrn(): empty list of specs
    95.           return NULL;        /* 'lh->error++' already done in 'expand' */
    96.   
    97.       rn = getrn(lh, data, &hash);
               ^
    98.   
    99.       if (*rn == NULL) {

crypto/lhash/lhash.c:99:9: Taking false branch
    97.       rn = getrn(lh, data, &hash);
    98.   
    99.       if (*rn == NULL) {
                   ^
    100.           if ((nn = OPENSSL_malloc(sizeof(*nn))) == NULL) {
    101.               lh->error++;

crypto/lhash/lhash.c:112:9: 
    110.           lh->num_items++;
    111.       } else {                    /* replace same key */
    112. >         ret = (*rn)->data;
    113.           (*rn)->data = data;
    114.           lh->num_replace++;

crypto/lhash/lhash.c:113:9: 
    111.       } else {                    /* replace same key */
    112.           ret = (*rn)->data;
    113. >         (*rn)->data = data;
    114.           lh->num_replace++;
    115.       }

crypto/lhash/lhash.c:114:9: 
    112.           ret = (*rn)->data;
    113.           (*rn)->data = data;
    114. >         lh->num_replace++;
    115.       }
    116.       return ret;

crypto/lhash/lhash.c:116:5: 
    114.           lh->num_replace++;
    115.       }
    116. >     return ret;
    117.   }
    118.   

crypto/lhash/lhash.c:117:1: return from a call to OPENSSL_LH_insert
    115.       }
    116.       return ret;
    117. > }
    118.   
    119.   void *OPENSSL_LH_delete(OPENSSL_LHASH *lh, const void *data)

crypto/objects/obj_lcl.h:12:1: return from a call to lh_OBJ_NAME_insert
  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;
  14.   DEFINE_LHASH_OF(ADDED_OBJ);

crypto/objects/o_names.c:234:9: Taking true branch
232.   
233.       ret = lh_OBJ_NAME_insert(names_lh, onp);
234.       if (ret != NULL) {
               ^
235.           /* free things */
236.           if ((name_funcs_stack != NULL)

crypto/objects/o_names.c:236:14: 
234.       if (ret != NULL) {
235.           /* free things */
236. >         if ((name_funcs_stack != NULL)
237.               && (sk_NAME_FUNCS_num(name_funcs_stack) > ret->type)) {
238.               /*

int OBJ_NAME_add(const char *name, int type, const char *data)
{
    OBJ_NAME *onp, *ret;
    int alias, ok = 0;
    if (!OBJ_NAME_init())
        return 0;
    CRYPTO_THREAD_write_lock(obj_lock);
    alias = type & OBJ_NAME_ALIAS;
    type &= ~OBJ_NAME_ALIAS;
    onp = OPENSSL_malloc(sizeof(*onp));
    if (onp == NULL) {
        goto unlock;
    }
    onp->name = name;
    onp->alias = alias;
    onp->type = type;
    onp->data = data;
    ret = lh_OBJ_NAME_insert(names_lh, onp);
    if (ret != NULL) {
        if ((name_funcs_stack != NULL)
            && (sk_NAME_FUNCS_num(name_funcs_stack) > ret->type)) {
            sk_NAME_FUNCS_value(name_funcs_stack,
                                ret->type)->free_func(ret->name, ret->type,
                                                      ret->data);
        }
        OPENSSL_free(ret);
    } else {
        if (lh_OBJ_NAME_error(names_lh)) {
            OPENSSL_free(onp);
            goto unlock;
        }
    }
    ok = 1;
unlock:
    CRYPTO_THREAD_unlock(obj_lock);
    return ok;
}
['int OBJ_NAME_add(const char *name, int type, const char *data)\n{\n    OBJ_NAME *onp, *ret;\n    int alias, ok = 0;\n    if (!OBJ_NAME_init())\n        return 0;\n    CRYPTO_THREAD_write_lock(obj_lock);\n    alias = type & OBJ_NAME_ALIAS;\n    type &= ~OBJ_NAME_ALIAS;\n    onp = OPENSSL_malloc(sizeof(*onp));\n    if (onp == NULL) {\n        goto unlock;\n    }\n    onp->name = name;\n    onp->alias = alias;\n    onp->type = type;\n    onp->data = data;\n    ret = lh_OBJ_NAME_insert(names_lh, onp);\n    if (ret != NULL) {\n        if ((name_funcs_stack != NULL)\n            && (sk_NAME_FUNCS_num(name_funcs_stack) > ret->type)) {\n            sk_NAME_FUNCS_value(name_funcs_stack,\n                                ret->type)->free_func(ret->name, ret->type,\n                                                      ret->data);\n        }\n        OPENSSL_free(ret);\n    } else {\n        if (lh_OBJ_NAME_error(names_lh)) {\n            OPENSSL_free(onp);\n            goto unlock;\n        }\n    }\n    ok = 1;\nunlock:\n    CRYPTO_THREAD_unlock(obj_lock);\n    return ok;\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}', '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    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}', 'void *OPENSSL_LH_insert(OPENSSL_LHASH *lh, void *data)\n{\n    unsigned long hash;\n    OPENSSL_LH_NODE *nn, **rn;\n    void *ret;\n    lh->error = 0;\n    if ((lh->up_load <= (lh->num_items * LH_LOAD_MULT / lh->num_nodes)) && !expand(lh))\n        return NULL;\n    rn = getrn(lh, data, &hash);\n    if (*rn == NULL) {\n        if ((nn = OPENSSL_malloc(sizeof(*nn))) == NULL) {\n            lh->error++;\n            return NULL;\n        }\n        nn->data = data;\n        nn->next = NULL;\n        nn->hash = hash;\n        *rn = nn;\n        ret = NULL;\n        lh->num_insert++;\n        lh->num_items++;\n    } else {\n        ret = (*rn)->data;\n        (*rn)->data = data;\n        lh->num_replace++;\n    }\n    return ret;\n}']