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


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

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

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

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

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

crypto/threads_pthread.c:111:1: start of procedure CRYPTO_THREAD_run_once()
    109.   }
    110.   
    111. > int CRYPTO_THREAD_run_once(CRYPTO_ONCE *once, void (*init)(void))
    112.   {
    113.       if (pthread_once(once, init) != 0)

crypto/threads_pthread.c:113:9: Taking false branch
    111.   int CRYPTO_THREAD_run_once(CRYPTO_ONCE *once, void (*init)(void))
    112.   {
    113.       if (pthread_once(once, init) != 0)
                   ^
    114.           return 0;
    115.   

crypto/threads_pthread.c:116:5: 
    114.           return 0;
    115.   
    116. >     return 1;
    117.   }
    118.   

crypto/threads_pthread.c:117:1: return from a call to CRYPTO_THREAD_run_once
    115.   
    116.       return 1;
    117. > }
    118.   
    119.   int CRYPTO_THREAD_init_local(CRYPTO_THREAD_LOCAL *key, void (*cleanup)(void *))

crypto/objects/o_names.c:78:12: Condition is true
  76.   int OBJ_NAME_init(void)
  77.   {
  78.       return RUN_ONCE(&init, o_names_init);
                   ^
  79.   }
  80.   

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

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

crypto/objects/o_names.c:213:10: Taking false branch
211.       int alias, ok = 0;
212.   
213.       if (!OBJ_NAME_init())
                ^
214.           return 0;
215.   

crypto/objects/o_names.c:216:5: 
214.           return 0;
215.   
216. >     alias = type & OBJ_NAME_ALIAS;
217.       type &= ~OBJ_NAME_ALIAS;
218.   

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

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

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

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

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

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

crypto/mem.c:204:9: Taking true branch
  202.   
  203.       FAILTEST();
  204.       if (allow_customize) {
                 ^
  205.           /*
  206.            * Disallow customization after the first allocation. We only set this

crypto/mem.c:210:9: 
  208.            * allocation.
  209.            */
  210. >         allow_customize = 0;
  211.       }
  212.   #if !defined(OPENSSL_NO_CRYPTO_MDEBUG) && !defined(FIPS_MODE)

crypto/mem.c:221:5: 
  219.       }
  220.   #else
  221. >     (void)(file); (void)(line);
  222.       ret = malloc(num);
  223.   #endif

crypto/mem.c:221:19: 
  219.       }
  220.   #else
  221. >     (void)(file); (void)(line);
  222.       ret = malloc(num);
  223.   #endif

crypto/mem.c:222:5: 
  220.   #else
  221.       (void)(file); (void)(line);
  222. >     ret = malloc(num);
  223.   #endif
  224.   

crypto/mem.c:225:5: 
  223.   #endif
  224.   
  225. >     return ret;
  226.   }
  227.   

crypto/mem.c:226:1: return from a call to CRYPTO_malloc
  224.   
  225.       return ret;
  226. > }
  227.   
  228.   void *CRYPTO_zalloc(size_t num, const char *file, int line)

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

crypto/objects/o_names.c:225:5: 
223.       }
224.   
225. >     onp->name = name;
226.       onp->alias = alias;
227.       onp->type = type;

crypto/objects/o_names.c:226:5: 
224.   
225.       onp->name = name;
226. >     onp->alias = alias;
227.       onp->type = type;
228.       onp->data = data;

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

crypto/objects/o_names.c:228:5: 
226.       onp->alias = alias;
227.       onp->type = type;
228. >     onp->data = data;
229.   
230.       CRYPTO_THREAD_write_lock(obj_lock);

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

crypto/threads_pthread.c:70:1: start of procedure CRYPTO_THREAD_write_lock()
  68.   }
  69.   
  70. > int CRYPTO_THREAD_write_lock(CRYPTO_RWLOCK *lock)
  71.   {
  72.   # ifdef USE_RWLOCK

crypto/threads_pthread.c:73:9: Taking true branch
  71.   {
  72.   # ifdef USE_RWLOCK
  73.       if (pthread_rwlock_wrlock(lock) != 0)
                ^
  74.           return 0;
  75.   # else

crypto/threads_pthread.c:74:9: 
  72.   # ifdef USE_RWLOCK
  73.       if (pthread_rwlock_wrlock(lock) != 0)
  74. >         return 0;
  75.   # else
  76.       if (pthread_mutex_lock(lock) != 0)

crypto/threads_pthread.c:81:1: return from a call to CRYPTO_THREAD_write_lock
  79.   
  80.       return 1;
  81. > }
  82.   
  83.   int CRYPTO_THREAD_unlock(CRYPTO_RWLOCK *lock)

crypto/objects/o_names.c:232:5: 
230.       CRYPTO_THREAD_write_lock(obj_lock);
231.   
232. >     ret = lh_OBJ_NAME_insert(names_lh, onp);
233.       if (ret != NULL) {
234.           /* 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:104:1: start of procedure OPENSSL_LH_insert()
    102.   }
    103.   
    104. > void *OPENSSL_LH_insert(OPENSSL_LHASH *lh, void *data)
    105.   {
    106.       unsigned long hash;

crypto/lhash/lhash.c:110:5: 
    108.       void *ret;
    109.   
    110. >     lh->error = 0;
    111.       if ((lh->up_load <= (lh->num_items * LH_LOAD_MULT / lh->num_nodes)) && !expand(lh))
    112.           return NULL;        /* 'lh->error++' already done in 'expand' */

crypto/lhash/lhash.c:111:10: Taking false branch
    109.   
    110.       lh->error = 0;
    111.       if ((lh->up_load <= (lh->num_items * LH_LOAD_MULT / lh->num_nodes)) && !expand(lh))
                    ^
    112.           return NULL;        /* 'lh->error++' already done in 'expand' */
    113.   

crypto/lhash/lhash.c:114:5: Skipping getrn(): empty list of specs
    112.           return NULL;        /* 'lh->error++' already done in 'expand' */
    113.   
    114.       rn = getrn(lh, data, &hash);
               ^
    115.   
    116.       if (*rn == NULL) {

crypto/lhash/lhash.c:116:9: Taking false branch
    114.       rn = getrn(lh, data, &hash);
    115.   
    116.       if (*rn == NULL) {
                   ^
    117.           if ((nn = OPENSSL_malloc(sizeof(*nn))) == NULL) {
    118.               lh->error++;

crypto/lhash/lhash.c:129:9: 
    127.           lh->num_items++;
    128.       } else {                    /* replace same key */
    129. >         ret = (*rn)->data;
    130.           (*rn)->data = data;
    131.           lh->num_replace++;

crypto/lhash/lhash.c:130:9: 
    128.       } else {                    /* replace same key */
    129.           ret = (*rn)->data;
    130. >         (*rn)->data = data;
    131.           lh->num_replace++;
    132.       }

crypto/lhash/lhash.c:131:9: 
    129.           ret = (*rn)->data;
    130.           (*rn)->data = data;
    131. >         lh->num_replace++;
    132.       }
    133.       return ret;

crypto/lhash/lhash.c:133:5: 
    131.           lh->num_replace++;
    132.       }
    133. >     return ret;
    134.   }
    135.   

crypto/lhash/lhash.c:134:1: return from a call to OPENSSL_LH_insert
    132.       }
    133.       return ret;
    134. > }
    135.   
    136.   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:233:9: Taking true branch
231.   
232.       ret = lh_OBJ_NAME_insert(names_lh, onp);
233.       if (ret != NULL) {
               ^
234.           /* free things */
235.           if ((name_funcs_stack != NULL)

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

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;
    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;
    CRYPTO_THREAD_write_lock(obj_lock);
    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    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    CRYPTO_THREAD_write_lock(obj_lock);\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}', '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    if (allow_customize) {\n        allow_customize = 0;\n    }\n#if !defined(OPENSSL_NO_CRYPTO_MDEBUG) && !defined(FIPS_MODE)\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 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 *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}']