crypto/asn1/tasn_new.c:152: error: MEMORY_LEAK
  memory dynamically allocated by call to `CRYPTO_zalloc()` at line 147, column 21 is not reachable after line 152, column 25.
Showing all 42 steps of the trace


crypto/asn1/tasn_new.c:92:1: start of procedure asn1_item_embed_new()
90.   }
91.   
92. > int asn1_item_embed_new(ASN1_VALUE **pval, const ASN1_ITEM *it, int embed)
93.   {
94.       const ASN1_TEMPLATE *tt = NULL;

crypto/asn1/tasn_new.c:94:5: 
92.   int asn1_item_embed_new(ASN1_VALUE **pval, const ASN1_ITEM *it, int embed)
93.   {
94. >     const ASN1_TEMPLATE *tt = NULL;
95.       const ASN1_EXTERN_FUNCS *ef;
96.       const ASN1_AUX *aux = it->funcs;

crypto/asn1/tasn_new.c:96:5: 
94.       const ASN1_TEMPLATE *tt = NULL;
95.       const ASN1_EXTERN_FUNCS *ef;
96. >     const ASN1_AUX *aux = it->funcs;
97.       ASN1_aux_cb *asn1_cb;
98.       ASN1_VALUE **pseqval;

crypto/asn1/tasn_new.c:100:9: Taking true branch
98.       ASN1_VALUE **pseqval;
99.       int i;
100.       if (aux && aux->asn1_cb)
               ^
101.           asn1_cb = aux->asn1_cb;
102.       else

crypto/asn1/tasn_new.c:100:16: Taking true branch
98.       ASN1_VALUE **pseqval;
99.       int i;
100.       if (aux && aux->asn1_cb)
                      ^
101.           asn1_cb = aux->asn1_cb;
102.       else

crypto/asn1/tasn_new.c:101:9: 
99.       int i;
100.       if (aux && aux->asn1_cb)
101. >         asn1_cb = aux->asn1_cb;
102.       else
103.           asn1_cb = 0;

crypto/asn1/tasn_new.c:109:5: 
107.   #endif
108.   
109. >     switch (it->itype) {
110.   
111.       case ASN1_ITYPE_EXTERN:

crypto/asn1/tasn_new.c:111:5: Switch condition is false. Skipping switch case
109.       switch (it->itype) {
110.   
111.       case ASN1_ITYPE_EXTERN:
           ^
112.           ef = it->funcs;
113.           if (ef && ef->asn1_ex_new) {

crypto/asn1/tasn_new.c:119:5: Switch condition is false. Skipping switch case
117.           break;
118.   
119.       case ASN1_ITYPE_PRIMITIVE:
           ^
120.           if (it->templates) {
121.               if (!asn1_template_new(pval, it->templates))

crypto/asn1/tasn_new.c:127:5: Switch condition is false. Skipping switch case
125.           break;
126.   
127.       case ASN1_ITYPE_MSTRING:
           ^
128.           if (!asn1_primitive_new(pval, it, embed))
129.               goto memerr;

crypto/asn1/tasn_new.c:132:5: Switch condition is true. Entering switch case
130.           break;
131.   
132.       case ASN1_ITYPE_CHOICE:
           ^
133.           if (asn1_cb) {
134.               i = asn1_cb(ASN1_OP_NEW_PRE, pval, it, NULL);

crypto/asn1/tasn_new.c:133:13: Taking true branch
131.   
132.       case ASN1_ITYPE_CHOICE:
133.           if (asn1_cb) {
                   ^
134.               i = asn1_cb(ASN1_OP_NEW_PRE, pval, it, NULL);
135.               if (!i)

crypto/asn1/tasn_new.c:134:13: Skipping __function_pointer__(): unresolved function pointer
132.       case ASN1_ITYPE_CHOICE:
133.           if (asn1_cb) {
134.               i = asn1_cb(ASN1_OP_NEW_PRE, pval, it, NULL);
                   ^
135.               if (!i)
136.                   goto auxerr;

crypto/asn1/tasn_new.c:135:18: Taking false branch
133.           if (asn1_cb) {
134.               i = asn1_cb(ASN1_OP_NEW_PRE, pval, it, NULL);
135.               if (!i)
                        ^
136.                   goto auxerr;
137.               if (i == 2) {

crypto/asn1/tasn_new.c:137:17: Taking false branch
135.               if (!i)
136.                   goto auxerr;
137.               if (i == 2) {
                       ^
138.   #ifndef OPENSSL_NO_CRYPTO_MDEBUG
139.                   OPENSSL_mem_debug_pop();

crypto/asn1/tasn_new.c:144:13: Taking false branch
142.               }
143.           }
144.           if (embed) {
                   ^
145.               memset(*pval, 0, it->size);
146.           } else {

crypto/asn1/tasn_new.c:147:13: 
145.               memset(*pval, 0, it->size);
146.           } else {
147. >             *pval = OPENSSL_zalloc(it->size);
148.               if (*pval == NULL)
149.                   goto memerr;

crypto/mem.c:157:1: start of procedure CRYPTO_zalloc()
  155.   }
  156.   
  157. > void *CRYPTO_zalloc(size_t num, const char *file, int line)
  158.   {
  159.       void *ret = CRYPTO_malloc(num, file, line);

crypto/mem.c:159:5: 
  157.   void *CRYPTO_zalloc(size_t num, const char *file, int line)
  158.   {
  159. >     void *ret = CRYPTO_malloc(num, file, line);
  160.   
  161.       if (ret != NULL)

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

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

crypto/mem.c:124:9: Taking false branch
    122.       void *ret = NULL;
    123.   
    124.       if (num <= 0)
                   ^
    125.           return NULL;
    126.   

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

crypto/mem.c:137:5: 
    135.       }
    136.   #else
    137. >     (void)file;
    138.       (void)line;
    139.       ret = malloc(num);

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

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

crypto/mem.c:154:5: 
    152.   #endif
    153.   
    154. >     return ret;
    155.   }
    156.   

crypto/mem.c:155:1: return from a call to CRYPTO_malloc
    153.   
    154.       return ret;
    155. > }
    156.   
    157.   void *CRYPTO_zalloc(size_t num, const char *file, int line)

crypto/mem.c:161:9: Taking true branch
  159.       void *ret = CRYPTO_malloc(num, file, line);
  160.   
  161.       if (ret != NULL)
                 ^
  162.           memset(ret, 0, num);
  163.       return ret;

crypto/mem.c:162:9: 
  160.   
  161.       if (ret != NULL)
  162. >         memset(ret, 0, num);
  163.       return ret;
  164.   }

crypto/mem.c:163:5: 
  161.       if (ret != NULL)
  162.           memset(ret, 0, num);
  163. >     return ret;
  164.   }
  165.   

crypto/mem.c:164:1: return from a call to CRYPTO_zalloc
  162.           memset(ret, 0, num);
  163.       return ret;
  164. > }
  165.   
  166.   void *CRYPTO_realloc(void *str, size_t num, const char *file, int line)

crypto/asn1/tasn_new.c:148:17: Taking false branch
146.           } else {
147.               *pval = OPENSSL_zalloc(it->size);
148.               if (*pval == NULL)
                       ^
149.                   goto memerr;
150.           }

crypto/asn1/tasn_new.c:151:9: 
149.                   goto memerr;
150.           }
151. >         asn1_set_choice_selector(pval, -1, it);
152.           if (asn1_cb && !asn1_cb(ASN1_OP_NEW_POST, pval, it, NULL))
153.               goto auxerr;

crypto/asn1/tasn_utl.c:88:1: start of procedure asn1_set_choice_selector()
  86.    */
  87.   
  88. > int asn1_set_choice_selector(ASN1_VALUE **pval, int value,
  89.                                const ASN1_ITEM *it)
  90.   {

crypto/asn1/tasn_utl.c:92:5: 
  90.   {
  91.       int *sel, ret;
  92. >     sel = offset2ptr(*pval, it->utype);
  93.       ret = *sel;
  94.       *sel = value;

crypto/asn1/tasn_utl.c:93:5: 
  91.       int *sel, ret;
  92.       sel = offset2ptr(*pval, it->utype);
  93. >     ret = *sel;
  94.       *sel = value;
  95.       return ret;

crypto/asn1/tasn_utl.c:94:5: 
  92.       sel = offset2ptr(*pval, it->utype);
  93.       ret = *sel;
  94. >     *sel = value;
  95.       return ret;
  96.   }

crypto/asn1/tasn_utl.c:95:5: 
  93.       ret = *sel;
  94.       *sel = value;
  95. >     return ret;
  96.   }
  97.   

crypto/asn1/tasn_utl.c:96:1: return from a call to asn1_set_choice_selector
  94.       *sel = value;
  95.       return ret;
  96. > }
  97.   
  98.   /*

crypto/asn1/tasn_new.c:152:13: Taking true branch
150.           }
151.           asn1_set_choice_selector(pval, -1, it);
152.           if (asn1_cb && !asn1_cb(ASN1_OP_NEW_POST, pval, it, NULL))
                   ^
153.               goto auxerr;
154.           break;

crypto/asn1/tasn_new.c:152:25: Skipping __function_pointer__(): unresolved function pointer
150.           }
151.           asn1_set_choice_selector(pval, -1, it);
152.           if (asn1_cb && !asn1_cb(ASN1_OP_NEW_POST, pval, it, NULL))
                               ^
153.               goto auxerr;
154.           break;

int asn1_item_embed_new(ASN1_VALUE **pval, const ASN1_ITEM *it, int embed)
{
    const ASN1_TEMPLATE *tt = NULL;
    const ASN1_EXTERN_FUNCS *ef;
    const ASN1_AUX *aux = it->funcs;
    ASN1_aux_cb *asn1_cb;
    ASN1_VALUE **pseqval;
    int i;
    if (aux && aux->asn1_cb)
        asn1_cb = aux->asn1_cb;
    else
        asn1_cb = 0;
#ifndef OPENSSL_NO_CRYPTO_MDEBUG
    OPENSSL_mem_debug_push(it->sname ? it->sname : "asn1_item_embed_new");
#endif
    switch (it->itype) {
    case ASN1_ITYPE_EXTERN:
        ef = it->funcs;
        if (ef && ef->asn1_ex_new) {
            if (!ef->asn1_ex_new(pval, it))
                goto memerr;
        }
        break;
    case ASN1_ITYPE_PRIMITIVE:
        if (it->templates) {
            if (!asn1_template_new(pval, it->templates))
                goto memerr;
        } else if (!asn1_primitive_new(pval, it, embed))
            goto memerr;
        break;
    case ASN1_ITYPE_MSTRING:
        if (!asn1_primitive_new(pval, it, embed))
            goto memerr;
        break;
    case ASN1_ITYPE_CHOICE:
        if (asn1_cb) {
            i = asn1_cb(ASN1_OP_NEW_PRE, pval, it, NULL);
            if (!i)
                goto auxerr;
            if (i == 2) {
#ifndef OPENSSL_NO_CRYPTO_MDEBUG
                OPENSSL_mem_debug_pop();
#endif
                return 1;
            }
        }
        if (embed) {
            memset(*pval, 0, it->size);
        } else {
            *pval = OPENSSL_zalloc(it->size);
            if (*pval == NULL)
                goto memerr;
        }
        asn1_set_choice_selector(pval, -1, it);
        if (asn1_cb && !asn1_cb(ASN1_OP_NEW_POST, pval, it, NULL))
            goto auxerr;
        break;
    case ASN1_ITYPE_NDEF_SEQUENCE:
    case ASN1_ITYPE_SEQUENCE:
        if (asn1_cb) {
            i = asn1_cb(ASN1_OP_NEW_PRE, pval, it, NULL);
            if (!i)
                goto auxerr;
            if (i == 2) {
#ifndef OPENSSL_NO_CRYPTO_MDEBUG
                OPENSSL_mem_debug_pop();
#endif
                return 1;
            }
        }
        if (embed) {
            memset(*pval, 0, it->size);
        } else {
            *pval = OPENSSL_zalloc(it->size);
            if (*pval == NULL)
                goto memerr;
        }
        asn1_do_lock(pval, 0, it);
        asn1_enc_init(pval, it);
        for (i = 0, tt = it->templates; i < it->tcount; tt++, i++) {
            pseqval = asn1_get_field_ptr(pval, tt);
            if (!asn1_template_new(pseqval, tt))
                goto memerr;
        }
        if (asn1_cb && !asn1_cb(ASN1_OP_NEW_POST, pval, it, NULL))
            goto auxerr;
        break;
    }
#ifndef OPENSSL_NO_CRYPTO_MDEBUG
    OPENSSL_mem_debug_pop();
#endif
    return 1;
 memerr:
    ASN1err(ASN1_F_ASN1_ITEM_EMBED_NEW, ERR_R_MALLOC_FAILURE);
#ifndef OPENSSL_NO_CRYPTO_MDEBUG
    OPENSSL_mem_debug_pop();
#endif
    return 0;
 auxerr:
    ASN1err(ASN1_F_ASN1_ITEM_EMBED_NEW, ASN1_R_AUX_ERROR);
    ASN1_item_ex_free(pval, it);
#ifndef OPENSSL_NO_CRYPTO_MDEBUG
    OPENSSL_mem_debug_pop();
#endif
    return 0;
}
['int asn1_item_embed_new(ASN1_VALUE **pval, const ASN1_ITEM *it, int embed)\n{\n    const ASN1_TEMPLATE *tt = NULL;\n    const ASN1_EXTERN_FUNCS *ef;\n    const ASN1_AUX *aux = it->funcs;\n    ASN1_aux_cb *asn1_cb;\n    ASN1_VALUE **pseqval;\n    int i;\n    if (aux && aux->asn1_cb)\n        asn1_cb = aux->asn1_cb;\n    else\n        asn1_cb = 0;\n#ifndef OPENSSL_NO_CRYPTO_MDEBUG\n    OPENSSL_mem_debug_push(it->sname ? it->sname : "asn1_item_embed_new");\n#endif\n    switch (it->itype) {\n    case ASN1_ITYPE_EXTERN:\n        ef = it->funcs;\n        if (ef && ef->asn1_ex_new) {\n            if (!ef->asn1_ex_new(pval, it))\n                goto memerr;\n        }\n        break;\n    case ASN1_ITYPE_PRIMITIVE:\n        if (it->templates) {\n            if (!asn1_template_new(pval, it->templates))\n                goto memerr;\n        } else if (!asn1_primitive_new(pval, it, embed))\n            goto memerr;\n        break;\n    case ASN1_ITYPE_MSTRING:\n        if (!asn1_primitive_new(pval, it, embed))\n            goto memerr;\n        break;\n    case ASN1_ITYPE_CHOICE:\n        if (asn1_cb) {\n            i = asn1_cb(ASN1_OP_NEW_PRE, pval, it, NULL);\n            if (!i)\n                goto auxerr;\n            if (i == 2) {\n#ifndef OPENSSL_NO_CRYPTO_MDEBUG\n                OPENSSL_mem_debug_pop();\n#endif\n                return 1;\n            }\n        }\n        if (embed) {\n            memset(*pval, 0, it->size);\n        } else {\n            *pval = OPENSSL_zalloc(it->size);\n            if (*pval == NULL)\n                goto memerr;\n        }\n        asn1_set_choice_selector(pval, -1, it);\n        if (asn1_cb && !asn1_cb(ASN1_OP_NEW_POST, pval, it, NULL))\n            goto auxerr;\n        break;\n    case ASN1_ITYPE_NDEF_SEQUENCE:\n    case ASN1_ITYPE_SEQUENCE:\n        if (asn1_cb) {\n            i = asn1_cb(ASN1_OP_NEW_PRE, pval, it, NULL);\n            if (!i)\n                goto auxerr;\n            if (i == 2) {\n#ifndef OPENSSL_NO_CRYPTO_MDEBUG\n                OPENSSL_mem_debug_pop();\n#endif\n                return 1;\n            }\n        }\n        if (embed) {\n            memset(*pval, 0, it->size);\n        } else {\n            *pval = OPENSSL_zalloc(it->size);\n            if (*pval == NULL)\n                goto memerr;\n        }\n        asn1_do_lock(pval, 0, it);\n        asn1_enc_init(pval, it);\n        for (i = 0, tt = it->templates; i < it->tcount; tt++, i++) {\n            pseqval = asn1_get_field_ptr(pval, tt);\n            if (!asn1_template_new(pseqval, tt))\n                goto memerr;\n        }\n        if (asn1_cb && !asn1_cb(ASN1_OP_NEW_POST, pval, it, NULL))\n            goto auxerr;\n        break;\n    }\n#ifndef OPENSSL_NO_CRYPTO_MDEBUG\n    OPENSSL_mem_debug_pop();\n#endif\n    return 1;\n memerr:\n    ASN1err(ASN1_F_ASN1_ITEM_EMBED_NEW, ERR_R_MALLOC_FAILURE);\n#ifndef OPENSSL_NO_CRYPTO_MDEBUG\n    OPENSSL_mem_debug_pop();\n#endif\n    return 0;\n auxerr:\n    ASN1err(ASN1_F_ASN1_ITEM_EMBED_NEW, ASN1_R_AUX_ERROR);\n    ASN1_item_ex_free(pval, it);\n#ifndef OPENSSL_NO_CRYPTO_MDEBUG\n    OPENSSL_mem_debug_pop();\n#endif\n    return 0;\n}', 'void *CRYPTO_zalloc(size_t num, const char *file, int line)\n{\n    void *ret = CRYPTO_malloc(num, file, line);\n    if (ret != NULL)\n        memset(ret, 0, num);\n    return ret;\n}', 'void *CRYPTO_malloc(size_t num, const char *file, int line)\n{\n    void *ret = NULL;\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    (void)file;\n    (void)line;\n    ret = malloc(num);\n#endif\n#ifndef OPENSSL_CPUID_OBJ\n    if (ret && (num > 2048)) {\n        extern unsigned char cleanse_ctr;\n        ((unsigned char *)ret)[0] = cleanse_ctr;\n    }\n#endif\n    return ret;\n}', 'int asn1_set_choice_selector(ASN1_VALUE **pval, int value,\n                             const ASN1_ITEM *it)\n{\n    int *sel, ret;\n    sel = offset2ptr(*pval, it->utype);\n    ret = *sel;\n    *sel = value;\n    return ret;\n}']