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:169:1: start of procedure CRYPTO_malloc()
  167.   #endif
  168.   
  169. > void *CRYPTO_malloc(size_t num, const char *file, int line)
  170.   {
  171.       void *ret = NULL;

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

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

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

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

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

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

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

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

crypto/mem.c:195:1: return from a call to CRYPTO_malloc
  193.   
  194.       return ret;
  195. > }
  196.   
  197.   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:73:1: start of procedure OPENSSL_LH_insert()
    71.   }
    72.   
    73. > void *OPENSSL_LH_insert(OPENSSL_LHASH *lh, void *data)
    74.   {
    75.       unsigned long hash;

crypto/lhash/lhash.c:79:5: 
    77.       void *ret;
    78.   
    79. >     lh->error = 0;
    80.       if ((lh->up_load <= (lh->num_items * LH_LOAD_MULT / lh->num_nodes)) && !expand(lh))
    81.           return NULL;        /* 'lh->error++' already done in 'expand' */

crypto/lhash/lhash.c:80:10: Taking false branch
    78.   
    79.       lh->error = 0;
    80.       if ((lh->up_load <= (lh->num_items * LH_LOAD_MULT / lh->num_nodes)) && !expand(lh))
                   ^
    81.           return NULL;        /* 'lh->error++' already done in 'expand' */
    82.   

crypto/lhash/lhash.c:83:5: Skipping getrn(): empty list of specs
    81.           return NULL;        /* 'lh->error++' already done in 'expand' */
    82.   
    83.       rn = getrn(lh, data, &hash);
              ^
    84.   
    85.       if (*rn == NULL) {

crypto/lhash/lhash.c:85:9: Taking false branch
    83.       rn = getrn(lh, data, &hash);
    84.   
    85.       if (*rn == NULL) {
                  ^
    86.           if ((nn = OPENSSL_malloc(sizeof(*nn))) == NULL) {
    87.               lh->error++;

crypto/lhash/lhash.c:99:9: 
    97.       } else {                    /* replace same key */
    98.   
    99. >         ret = (*rn)->data;
    100.           (*rn)->data = data;
    101.           lh->num_replace++;

crypto/lhash/lhash.c:100:9: 
    98.   
    99.           ret = (*rn)->data;
    100. >         (*rn)->data = data;
    101.           lh->num_replace++;
    102.       }

crypto/lhash/lhash.c:101:9: 
    99.           ret = (*rn)->data;
    100.           (*rn)->data = data;
    101. >         lh->num_replace++;
    102.       }
    103.       return (ret);

crypto/lhash/lhash.c:103:5: 
    101.           lh->num_replace++;
    102.       }
    103. >     return (ret);
    104.   }
    105.   

crypto/lhash/lhash.c:104:1: return from a call to OPENSSL_LH_insert
    102.       }
    103.       return (ret);
    104. > }
    105.   
    106.   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    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}']