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


crypto/objects/o_names.c:180:1: start of procedure OBJ_NAME_add()
178.   }
179.   
180. > int OBJ_NAME_add(const char *name, int type, const char *data)
181.   {
182.       OBJ_NAME *onp, *ret;

crypto/objects/o_names.c:185:10: Taking true branch
183.       int alias;
184.   
185.       if ((names_lh == NULL) && !OBJ_NAME_init())
                ^
186.           return (0);
187.   

crypto/objects/o_names.c:185:32: 
183.       int alias;
184.   
185. >     if ((names_lh == NULL) && !OBJ_NAME_init())
186.           return (0);
187.   

crypto/objects/o_names.c:65:1: start of procedure OBJ_NAME_init()
  63.   static int obj_name_cmp(const OBJ_NAME *a, const OBJ_NAME *b);
  64.   
  65. > int OBJ_NAME_init(void)
  66.   {
  67.       if (names_lh != NULL)

crypto/objects/o_names.c:67:9: Taking false branch
  65.   int OBJ_NAME_init(void)
  66.   {
  67.       if (names_lh != NULL)
                ^
  68.           return (1);
  69.       CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_DISABLE);

crypto/objects/o_names.c:69:5: 
  67.       if (names_lh != NULL)
  68.           return (1);
  69. >     CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_DISABLE);
  70.       names_lh = lh_OBJ_NAME_new(obj_name_hash, obj_name_cmp);
  71.       CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ENABLE);

crypto/mem_dbg.c:108:1: start of procedure CRYPTO_mem_ctrl()
    106.   #endif
    107.   
    108. > int CRYPTO_mem_ctrl(int mode)
    109.   {
    110.   #ifdef OPENSSL_NO_CRYPTO_MDEBUG

crypto/mem_dbg.c:111:5: 
    109.   {
    110.   #ifdef OPENSSL_NO_CRYPTO_MDEBUG
    111. >     return mode - mode;
    112.   #else
    113.       int ret = mh_mode;

crypto/mem_dbg.c:178:1: return from a call to CRYPTO_mem_ctrl
    176.       return (ret);
    177.   #endif
    178. > }
    179.   
    180.   #ifndef OPENSSL_NO_CRYPTO_MDEBUG

crypto/objects/o_names.c:70:5: 
  68.           return (1);
  69.       CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_DISABLE);
  70. >     names_lh = lh_OBJ_NAME_new(obj_name_hash, obj_name_cmp);
  71.       CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ENABLE);
  72.       return (names_lh != NULL);

crypto/objects/obj_lcl.h:12:1: start of procedure lh_OBJ_NAME_new()
    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/obj_lcl.h:12:1: return from a call to lh_OBJ_NAME_new
    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:71:5: 
  69.       CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_DISABLE);
  70.       names_lh = lh_OBJ_NAME_new(obj_name_hash, obj_name_cmp);
  71. >     CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ENABLE);
  72.       return (names_lh != NULL);
  73.   }

crypto/mem_dbg.c:108:1: start of procedure CRYPTO_mem_ctrl()
    106.   #endif
    107.   
    108. > int CRYPTO_mem_ctrl(int mode)
    109.   {
    110.   #ifdef OPENSSL_NO_CRYPTO_MDEBUG

crypto/mem_dbg.c:111:5: 
    109.   {
    110.   #ifdef OPENSSL_NO_CRYPTO_MDEBUG
    111. >     return mode - mode;
    112.   #else
    113.       int ret = mh_mode;

crypto/mem_dbg.c:178:1: return from a call to CRYPTO_mem_ctrl
    176.       return (ret);
    177.   #endif
    178. > }
    179.   
    180.   #ifndef OPENSSL_NO_CRYPTO_MDEBUG

crypto/objects/o_names.c:72:13: Condition is true
  70.       names_lh = lh_OBJ_NAME_new(obj_name_hash, obj_name_cmp);
  71.       CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ENABLE);
  72.       return (names_lh != NULL);
                    ^
  73.   }
  74.   

crypto/objects/o_names.c:72:5: 
  70.       names_lh = lh_OBJ_NAME_new(obj_name_hash, obj_name_cmp);
  71.       CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ENABLE);
  72. >     return (names_lh != NULL);
  73.   }
  74.   

crypto/objects/o_names.c:73:1: return from a call to OBJ_NAME_init
  71.       CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ENABLE);
  72.       return (names_lh != NULL);
  73. > }
  74.   
  75.   int OBJ_NAME_new_index(unsigned long (*hash_func) (const char *),

crypto/objects/o_names.c:185:32: Taking false branch
183.       int alias;
184.   
185.       if ((names_lh == NULL) && !OBJ_NAME_init())
                                      ^
186.           return (0);
187.   

crypto/objects/o_names.c:188:5: 
186.           return (0);
187.   
188. >     alias = type & OBJ_NAME_ALIAS;
189.       type &= ~OBJ_NAME_ALIAS;
190.   

crypto/objects/o_names.c:189:5: 
187.   
188.       alias = type & OBJ_NAME_ALIAS;
189. >     type &= ~OBJ_NAME_ALIAS;
190.   
191.       onp = OPENSSL_malloc(sizeof(*onp));

crypto/objects/o_names.c:191:5: 
189.       type &= ~OBJ_NAME_ALIAS;
190.   
191. >     onp = OPENSSL_malloc(sizeof(*onp));
192.       if (onp == NULL) {
193.           /* ERROR */

crypto/mem.c:71:1: start of procedure CRYPTO_malloc()
  69.   }
  70.   
  71. > void *CRYPTO_malloc(size_t num, const char *file, int line)
  72.   {
  73.       void *ret = NULL;

crypto/mem.c:73:5: 
  71.   void *CRYPTO_malloc(size_t num, const char *file, int line)
  72.   {
  73. >     void *ret = NULL;
  74.   
  75.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)

crypto/mem.c:75:9: Taking false branch
  73.       void *ret = NULL;
  74.   
  75.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
                ^
  76.           return malloc_impl(num, file, line);
  77.   

crypto/mem.c:78:9: Taking false branch
  76.           return malloc_impl(num, file, line);
  77.   
  78.       if (num <= 0)
                ^
  79.           return NULL;
  80.   

crypto/mem.c:81:5: 
  79.           return NULL;
  80.   
  81. >     allow_customize = 0;
  82.   #ifndef OPENSSL_NO_CRYPTO_MDEBUG
  83.       if (call_malloc_debug) {

crypto/mem.c:91:5: 
  89.       }
  90.   #else
  91. >     osslargused(file); osslargused(line);
  92.       ret = malloc(num);
  93.   #endif

crypto/mem.c:91:24: 
  89.       }
  90.   #else
  91. >     osslargused(file); osslargused(line);
  92.       ret = malloc(num);
  93.   #endif

crypto/mem.c:92:5: 
  90.   #else
  91.       osslargused(file); osslargused(line);
  92. >     ret = malloc(num);
  93.   #endif
  94.   

crypto/mem.c:95:5: 
  93.   #endif
  94.   
  95. >     return ret;
  96.   }
  97.   

crypto/mem.c:96:1: return from a call to CRYPTO_malloc
  94.   
  95.       return ret;
  96. > }
  97.   
  98.   void *CRYPTO_zalloc(size_t num, const char *file, int line)

crypto/objects/o_names.c:192:9: Taking false branch
190.   
191.       onp = OPENSSL_malloc(sizeof(*onp));
192.       if (onp == NULL) {
               ^
193.           /* ERROR */
194.           return 0;

crypto/objects/o_names.c:197:5: 
195.       }
196.   
197. >     onp->name = name;
198.       onp->alias = alias;
199.       onp->type = type;

crypto/objects/o_names.c:198:5: 
196.   
197.       onp->name = name;
198. >     onp->alias = alias;
199.       onp->type = type;
200.       onp->data = data;

crypto/objects/o_names.c:199:5: 
197.       onp->name = name;
198.       onp->alias = alias;
199. >     onp->type = type;
200.       onp->data = data;
201.   

crypto/objects/o_names.c:200:5: 
198.       onp->alias = alias;
199.       onp->type = type;
200. >     onp->data = data;
201.   
202.       ret = lh_OBJ_NAME_insert(names_lh, onp);

crypto/objects/o_names.c:202:5: 
200.       onp->data = data;
201.   
202. >     ret = lh_OBJ_NAME_insert(names_lh, onp);
203.       if (ret != NULL) {
204.           /* 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:70:1: start of procedure OPENSSL_LH_insert()
    68.   }
    69.   
    70. > void *OPENSSL_LH_insert(OPENSSL_LHASH *lh, void *data)
    71.   {
    72.       unsigned long hash;

crypto/lhash/lhash.c:76:5: 
    74.       void *ret;
    75.   
    76. >     lh->error = 0;
    77.       if (lh->up_load <= (lh->num_items * LH_LOAD_MULT / lh->num_nodes))
    78.           expand(lh);

crypto/lhash/lhash.c:77:9: Taking false branch
    75.   
    76.       lh->error = 0;
    77.       if (lh->up_load <= (lh->num_items * LH_LOAD_MULT / lh->num_nodes))
                  ^
    78.           expand(lh);
    79.   

crypto/lhash/lhash.c:80:5: Skipping getrn(): empty list of specs
    78.           expand(lh);
    79.   
    80.       rn = getrn(lh, data, &hash);
              ^
    81.   
    82.       if (*rn == NULL) {

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

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

crypto/lhash/lhash.c:97:9: 
    95.   
    96.           ret = (*rn)->data;
    97. >         (*rn)->data = data;
    98.           lh->num_replace++;
    99.       }

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

crypto/lhash/lhash.c:100:5: 
    98.           lh->num_replace++;
    99.       }
    100. >     return (ret);
    101.   }
    102.   

crypto/lhash/lhash.c:101:1: return from a call to OPENSSL_LH_insert
    99.       }
    100.       return (ret);
    101. > }
    102.   
    103.   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:203:9: Taking true branch
201.   
202.       ret = lh_OBJ_NAME_insert(names_lh, onp);
203.       if (ret != NULL) {
               ^
204.           /* free things */
205.           if ((name_funcs_stack != NULL)

crypto/objects/o_names.c:205:14: 
203.       if (ret != NULL) {
204.           /* free things */
205. >         if ((name_funcs_stack != NULL)
206.               && (sk_NAME_FUNCS_num(name_funcs_stack) > ret->type)) {
207.               /*

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)) {
            OPENSSL_free(onp);
            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            OPENSSL_free(onp);\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_THREAD_run_once(&memdbg_init, do_memdbg_init);\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}', '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 *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))\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}']