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


crypto/objects/o_names.c:171:1: start of procedure OBJ_NAME_add()
169.   }
170.   
171. > int OBJ_NAME_add(const char *name, int type, const char *data)
172.   {
173.       OBJ_NAME *onp, *ret;

crypto/objects/o_names.c:176:10: Taking true branch
174.       int alias;
175.   
176.       if ((names_lh == NULL) && !OBJ_NAME_init())
                ^
177.           return (0);
178.   

crypto/objects/o_names.c:176:32: 
174.       int alias;
175.   
176. >     if ((names_lh == NULL) && !OBJ_NAME_init())
177.           return (0);
178.   

crypto/objects/o_names.c:56:1: start of procedure OBJ_NAME_init()
  54.   static int obj_name_cmp(const OBJ_NAME *a, const OBJ_NAME *b);
  55.   
  56. > int OBJ_NAME_init(void)
  57.   {
  58.       if (names_lh != NULL)

crypto/objects/o_names.c:58:9: Taking false branch
  56.   int OBJ_NAME_init(void)
  57.   {
  58.       if (names_lh != NULL)
                ^
  59.           return (1);
  60.       CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_DISABLE);

crypto/objects/o_names.c:60:5: 
  58.       if (names_lh != NULL)
  59.           return (1);
  60. >     CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_DISABLE);
  61.       names_lh = lh_OBJ_NAME_new(obj_name_hash, obj_name_cmp);
  62.       CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ENABLE);

crypto/mem_dbg.c:204:1: start of procedure CRYPTO_mem_ctrl()
    202.   #endif
    203.   
    204. > int CRYPTO_mem_ctrl(int mode)
    205.   {
    206.   #ifdef OPENSSL_NO_CRYPTO_MDEBUG

crypto/mem_dbg.c:207:5: 
    205.   {
    206.   #ifdef OPENSSL_NO_CRYPTO_MDEBUG
    207. >     return mode - mode;
    208.   #else
    209.       int ret = mh_mode;

crypto/mem_dbg.c:273:1: return from a call to CRYPTO_mem_ctrl
    271.       return (ret);
    272.   #endif
    273. > }
    274.   
    275.   #ifndef OPENSSL_NO_CRYPTO_MDEBUG

crypto/objects/o_names.c:61:5: 
  59.           return (1);
  60.       CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_DISABLE);
  61. >     names_lh = lh_OBJ_NAME_new(obj_name_hash, obj_name_cmp);
  62.       CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ENABLE);
  63.       return (names_lh != NULL);

crypto/objects/obj_lcl.h:5:1: start of procedure lh_OBJ_NAME_new()
    3.   typedef struct name_funcs_st NAME_FUNCS;
    4.   DEFINE_STACK_OF(NAME_FUNCS)
    5. > DEFINE_LHASH_OF(OBJ_NAME);
    6.   typedef struct added_obj_st ADDED_OBJ;
    7.   DEFINE_LHASH_OF(ADDED_OBJ);

crypto/objects/obj_lcl.h:5:1: return from a call to lh_OBJ_NAME_new
    3.   typedef struct name_funcs_st NAME_FUNCS;
    4.   DEFINE_STACK_OF(NAME_FUNCS)
    5. > DEFINE_LHASH_OF(OBJ_NAME);
    6.   typedef struct added_obj_st ADDED_OBJ;
    7.   DEFINE_LHASH_OF(ADDED_OBJ);

crypto/objects/o_names.c:62:5: 
  60.       CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_DISABLE);
  61.       names_lh = lh_OBJ_NAME_new(obj_name_hash, obj_name_cmp);
  62. >     CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ENABLE);
  63.       return (names_lh != NULL);
  64.   }

crypto/mem_dbg.c:204:1: start of procedure CRYPTO_mem_ctrl()
    202.   #endif
    203.   
    204. > int CRYPTO_mem_ctrl(int mode)
    205.   {
    206.   #ifdef OPENSSL_NO_CRYPTO_MDEBUG

crypto/mem_dbg.c:207:5: 
    205.   {
    206.   #ifdef OPENSSL_NO_CRYPTO_MDEBUG
    207. >     return mode - mode;
    208.   #else
    209.       int ret = mh_mode;

crypto/mem_dbg.c:273:1: return from a call to CRYPTO_mem_ctrl
    271.       return (ret);
    272.   #endif
    273. > }
    274.   
    275.   #ifndef OPENSSL_NO_CRYPTO_MDEBUG

crypto/objects/o_names.c:63:13: Condition is true
  61.       names_lh = lh_OBJ_NAME_new(obj_name_hash, obj_name_cmp);
  62.       CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ENABLE);
  63.       return (names_lh != NULL);
                    ^
  64.   }
  65.   

crypto/objects/o_names.c:63:5: 
  61.       names_lh = lh_OBJ_NAME_new(obj_name_hash, obj_name_cmp);
  62.       CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ENABLE);
  63. >     return (names_lh != NULL);
  64.   }
  65.   

crypto/objects/o_names.c:64:1: return from a call to OBJ_NAME_init
  62.       CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ENABLE);
  63.       return (names_lh != NULL);
  64. > }
  65.   
  66.   int OBJ_NAME_new_index(unsigned long (*hash_func) (const char *),

crypto/objects/o_names.c:176:32: Taking false branch
174.       int alias;
175.   
176.       if ((names_lh == NULL) && !OBJ_NAME_init())
                                      ^
177.           return (0);
178.   

crypto/objects/o_names.c:179:5: 
177.           return (0);
178.   
179. >     alias = type & OBJ_NAME_ALIAS;
180.       type &= ~OBJ_NAME_ALIAS;
181.   

crypto/objects/o_names.c:180:5: 
178.   
179.       alias = type & OBJ_NAME_ALIAS;
180. >     type &= ~OBJ_NAME_ALIAS;
181.   
182.       onp = OPENSSL_malloc(sizeof(*onp));

crypto/objects/o_names.c:182:5: 
180.       type &= ~OBJ_NAME_ALIAS;
181.   
182. >     onp = OPENSSL_malloc(sizeof(*onp));
183.       if (onp == NULL) {
184.           /* ERROR */

crypto/mem.c:119:1: start of procedure CRYPTO_malloc()
  117.   }
  118.   
  119. > void *CRYPTO_malloc(size_t num, const char *file, int line)
  120.   {
  121.       void *ret = NULL;

crypto/mem.c:121:5: 
  119.   void *CRYPTO_malloc(size_t num, const char *file, int line)
  120.   {
  121. >     void *ret = NULL;
  122.   
  123.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)

crypto/mem.c:123:9: Taking false branch
  121.       void *ret = NULL;
  122.   
  123.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
                 ^
  124.           return malloc_impl(num, file, line);
  125.   

crypto/mem.c:126:9: Taking false branch
  124.           return malloc_impl(num, file, line);
  125.   
  126.       if (num <= 0)
                 ^
  127.           return NULL;
  128.   

crypto/mem.c:129:5: 
  127.           return NULL;
  128.   
  129. >     allow_customize = 0;
  130.   #ifndef OPENSSL_NO_CRYPTO_MDEBUG
  131.       if (call_malloc_debug) {

crypto/mem.c:139:5: 
  137.       }
  138.   #else
  139. >     osslargused(file); osslargused(line);
  140.       ret = malloc(num);
  141.   #endif

crypto/mem.c:139:24: 
  137.       }
  138.   #else
  139. >     osslargused(file); osslargused(line);
  140.       ret = malloc(num);
  141.   #endif

crypto/mem.c:140:5: 
  138.   #else
  139.       osslargused(file); osslargused(line);
  140. >     ret = malloc(num);
  141.   #endif
  142.   

crypto/mem.c:143:5: 
  141.   #endif
  142.   
  143. >     return ret;
  144.   }
  145.   

crypto/mem.c:144:1: return from a call to CRYPTO_malloc
  142.   
  143.       return ret;
  144. > }
  145.   
  146.   void *CRYPTO_zalloc(size_t num, const char *file, int line)

crypto/objects/o_names.c:183:9: Taking false branch
181.   
182.       onp = OPENSSL_malloc(sizeof(*onp));
183.       if (onp == NULL) {
               ^
184.           /* ERROR */
185.           return (0);

crypto/objects/o_names.c:188:5: 
186.       }
187.   
188. >     onp->name = name;
189.       onp->alias = alias;
190.       onp->type = type;

crypto/objects/o_names.c:189:5: 
187.   
188.       onp->name = name;
189. >     onp->alias = alias;
190.       onp->type = type;
191.       onp->data = data;

crypto/objects/o_names.c:190:5: 
188.       onp->name = name;
189.       onp->alias = alias;
190. >     onp->type = type;
191.       onp->data = data;
192.   

crypto/objects/o_names.c:191:5: 
189.       onp->alias = alias;
190.       onp->type = type;
191. >     onp->data = data;
192.   
193.       ret = lh_OBJ_NAME_insert(names_lh, onp);

crypto/objects/o_names.c:193:5: 
191.       onp->data = data;
192.   
193. >     ret = lh_OBJ_NAME_insert(names_lh, onp);
194.       if (ret != NULL) {
195.           /* free things */

crypto/objects/obj_lcl.h:5:1: start of procedure lh_OBJ_NAME_insert()
  3.   typedef struct name_funcs_st NAME_FUNCS;
  4.   DEFINE_STACK_OF(NAME_FUNCS)
  5. > DEFINE_LHASH_OF(OBJ_NAME);
  6.   typedef struct added_obj_st ADDED_OBJ;
  7.   DEFINE_LHASH_OF(ADDED_OBJ);

crypto/lhash/lhash.c:155:1: start of procedure lh_insert()
    153.   }
    154.   
    155. > void *lh_insert(_LHASH *lh, void *data)
    156.   {
    157.       unsigned long hash;

crypto/lhash/lhash.c:161:5: 
    159.       void *ret;
    160.   
    161. >     lh->error = 0;
    162.       if (lh->up_load <= (lh->num_items * LH_LOAD_MULT / lh->num_nodes))
    163.           expand(lh);

crypto/lhash/lhash.c:162:9: Taking false branch
    160.   
    161.       lh->error = 0;
    162.       if (lh->up_load <= (lh->num_items * LH_LOAD_MULT / lh->num_nodes))
                   ^
    163.           expand(lh);
    164.   

crypto/lhash/lhash.c:165:5: Skipping getrn(): empty list of specs
    163.           expand(lh);
    164.   
    165.       rn = getrn(lh, data, &hash);
               ^
    166.   
    167.       if (*rn == NULL) {

crypto/lhash/lhash.c:167:9: Taking false branch
    165.       rn = getrn(lh, data, &hash);
    166.   
    167.       if (*rn == NULL) {
                   ^
    168.           if ((nn = OPENSSL_malloc(sizeof(*nn))) == NULL) {
    169.               lh->error++;

crypto/lhash/lhash.c:181:9: 
    179.       } else {                    /* replace same key */
    180.   
    181. >         ret = (*rn)->data;
    182.           (*rn)->data = data;
    183.           lh->num_replace++;

crypto/lhash/lhash.c:182:9: 
    180.   
    181.           ret = (*rn)->data;
    182. >         (*rn)->data = data;
    183.           lh->num_replace++;
    184.       }

crypto/lhash/lhash.c:183:9: 
    181.           ret = (*rn)->data;
    182.           (*rn)->data = data;
    183. >         lh->num_replace++;
    184.       }
    185.       return (ret);

crypto/lhash/lhash.c:185:5: 
    183.           lh->num_replace++;
    184.       }
    185. >     return (ret);
    186.   }
    187.   

crypto/lhash/lhash.c:186:1: return from a call to lh_insert
    184.       }
    185.       return (ret);
    186. > }
    187.   
    188.   void *lh_delete(_LHASH *lh, const void *data)

crypto/objects/obj_lcl.h:5:1: return from a call to lh_OBJ_NAME_insert
  3.   typedef struct name_funcs_st NAME_FUNCS;
  4.   DEFINE_STACK_OF(NAME_FUNCS)
  5. > DEFINE_LHASH_OF(OBJ_NAME);
  6.   typedef struct added_obj_st ADDED_OBJ;
  7.   DEFINE_LHASH_OF(ADDED_OBJ);

int OBJ_NAME_add(const char *name, int type, const char *data)
{
    OBJ_NAME *onp, *ret;
    int alias;
    if ((names_lh == NULL) && !OBJ_NAME_init())
        return (0);
    alias = type & OBJ_NAME_ALIAS;
    type &= ~OBJ_NAME_ALIAS;
    onp = OPENSSL_malloc(sizeof(*onp));
    if (onp == NULL) {
        return (0);
    }
    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)) {
            return (0);
        }
    }
    return (1);
}
['int OBJ_NAME_add(const char *name, int type, const char *data)\n{\n    OBJ_NAME *onp, *ret;\n    int alias;\n    if ((names_lh == NULL) && !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        return (0);\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            return (0);\n        }\n    }\n    return (1);\n}', 'int OBJ_NAME_init(void)\n{\n    if (names_lh != NULL)\n        return (1);\n    CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_DISABLE);\n    names_lh = lh_OBJ_NAME_new(obj_name_hash, obj_name_cmp);\n    CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ENABLE);\n    return (names_lh != NULL);\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    CRYPTO_w_lock(CRYPTO_LOCK_MALLOC);\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_THREADID cur;\n            CRYPTO_THREADID_current(&cur);\n            if (!num_disable\n                || CRYPTO_THREADID_cmp(&disabling_threadid, &cur)) {\n                CRYPTO_w_unlock(CRYPTO_LOCK_MALLOC);\n                CRYPTO_w_lock(CRYPTO_LOCK_MALLOC2);\n                CRYPTO_w_lock(CRYPTO_LOCK_MALLOC);\n                mh_mode &= ~CRYPTO_MEM_CHECK_ENABLE;\n                CRYPTO_THREADID_cpy(&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_w_unlock(CRYPTO_LOCK_MALLOC2);\n                }\n            }\n        }\n        break;\n    }\n    CRYPTO_w_unlock(CRYPTO_LOCK_MALLOC);\n    return (ret);\n#endif\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}', 'void *lh_insert(_LHASH *lh, void *data)\n{\n    unsigned long hash;\n    LHASH_NODE *nn, **rn;\n    void *ret;\n    lh->error = 0;\n    if (lh->up_load <= (lh->num_items * LH_LOAD_MULT / lh->num_nodes))\n        expand(lh);\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}']