crypto/asn1/tasn_new.c:285: error: MEMORY_LEAK
  memory dynamically allocated by call to `sk_ASN1_VALUE_new_null()` at line 268, column 17 is not reachable after line 285, column 1.
Showing all 60 steps of the trace


crypto/asn1/tasn_new.c:241:1: start of procedure asn1_template_new()
239.   }
240.   
241. > static int asn1_template_new(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt)
242.   {
243.       const ASN1_ITEM *it = ASN1_ITEM_ptr(tt->item);

crypto/asn1/tasn_new.c:243:5: 
241.   static int asn1_template_new(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt)
242.   {
243. >     const ASN1_ITEM *it = ASN1_ITEM_ptr(tt->item);
244.       int embed = tt->flags & ASN1_TFLG_EMBED;
245.       ASN1_VALUE *tval;

crypto/asn1/tasn_new.c:244:5: 
242.   {
243.       const ASN1_ITEM *it = ASN1_ITEM_ptr(tt->item);
244. >     int embed = tt->flags & ASN1_TFLG_EMBED;
245.       ASN1_VALUE *tval;
246.       int ret;

crypto/asn1/tasn_new.c:247:9: Taking true branch
245.       ASN1_VALUE *tval;
246.       int ret;
247.       if (embed) {
               ^
248.           tval = (ASN1_VALUE *)pval;
249.           pval = &tval;

crypto/asn1/tasn_new.c:248:9: 
246.       int ret;
247.       if (embed) {
248. >         tval = (ASN1_VALUE *)pval;
249.           pval = &tval;
250.       }

crypto/asn1/tasn_new.c:249:9: 
247.       if (embed) {
248.           tval = (ASN1_VALUE *)pval;
249. >         pval = &tval;
250.       }
251.       if (tt->flags & ASN1_TFLG_OPTIONAL) {

crypto/asn1/tasn_new.c:251:9: Taking false branch
249.           pval = &tval;
250.       }
251.       if (tt->flags & ASN1_TFLG_OPTIONAL) {
               ^
252.           asn1_template_clear(pval, tt);
253.           return 1;

crypto/asn1/tasn_new.c:257:9: Taking false branch
255.       /* If ANY DEFINED BY nothing to do */
256.   
257.       if (tt->flags & ASN1_TFLG_ADB_MASK) {
               ^
258.           *pval = NULL;
259.           return 1;

crypto/asn1/tasn_new.c:266:9: Taking true branch
264.   #endif
265.       /* If SET OF or SEQUENCE OF, its a STACK */
266.       if (tt->flags & ASN1_TFLG_SK_MASK) {
               ^
267.           STACK_OF(ASN1_VALUE) *skval;
268.           skval = sk_ASN1_VALUE_new_null();

crypto/asn1/tasn_new.c:268:9: 
266.       if (tt->flags & ASN1_TFLG_SK_MASK) {
267.           STACK_OF(ASN1_VALUE) *skval;
268. >         skval = sk_ASN1_VALUE_new_null();
269.           if (!skval) {
270.               ASN1err(ASN1_F_ASN1_TEMPLATE_NEW, ERR_R_MALLOC_FAILURE);

include/openssl/asn1t.h:966:1: start of procedure sk_ASN1_VALUE_new_null()
  964.   DECLARE_ASN1_ITEM(ZLONG)
  965.   
  966. > DEFINE_STACK_OF(ASN1_VALUE)
  967.   
  968.   /* Functions used internally by the ASN1 code */

crypto/stack/stack.c:144:1: start of procedure sk_new_null()
    142.   }
    143.   
    144. > _STACK *sk_new_null(void)
    145.   {
    146.       return sk_new((int (*)(const void *, const void *))0);

crypto/stack/stack.c:146:5: 
    144.   _STACK *sk_new_null(void)
    145.   {
    146. >     return sk_new((int (*)(const void *, const void *))0);
    147.   }
    148.   

crypto/stack/stack.c:149:1: start of procedure sk_new()
      147.   }
      148.   
      149. > _STACK *sk_new(int (*c) (const void *, const void *))
      150.   {
      151.       _STACK *ret;

crypto/stack/stack.c:153:9: 
      151.       _STACK *ret;
      152.   
      153. >     if ((ret = OPENSSL_zalloc(sizeof(_STACK))) == NULL)
      154.           goto err;
      155.       if ((ret->data = OPENSSL_zalloc(sizeof(*ret->data) * MIN_NODES)) == NULL)

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

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

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 (num <= 0)

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

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

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

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

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

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

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

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

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

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

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

crypto/stack/stack.c:153:9: Taking false branch
      151.       _STACK *ret;
      152.   
      153.       if ((ret = OPENSSL_zalloc(sizeof(_STACK))) == NULL)
                     ^
      154.           goto err;
      155.       if ((ret->data = OPENSSL_zalloc(sizeof(*ret->data) * MIN_NODES)) == NULL)

crypto/stack/stack.c:155:9: 
      153.       if ((ret = OPENSSL_zalloc(sizeof(_STACK))) == NULL)
      154.           goto err;
      155. >     if ((ret->data = OPENSSL_zalloc(sizeof(*ret->data) * MIN_NODES)) == NULL)
      156.           goto err;
      157.       ret->comp = c;

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

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

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 (num <= 0)

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

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

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

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

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

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

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

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

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

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

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

crypto/stack/stack.c:155:9: Taking false branch
      153.       if ((ret = OPENSSL_zalloc(sizeof(_STACK))) == NULL)
      154.           goto err;
      155.       if ((ret->data = OPENSSL_zalloc(sizeof(*ret->data) * MIN_NODES)) == NULL)
                     ^
      156.           goto err;
      157.       ret->comp = c;

crypto/stack/stack.c:157:5: 
      155.       if ((ret->data = OPENSSL_zalloc(sizeof(*ret->data) * MIN_NODES)) == NULL)
      156.           goto err;
      157. >     ret->comp = c;
      158.       ret->num_alloc = MIN_NODES;
      159.       return (ret);

crypto/stack/stack.c:158:5: 
      156.           goto err;
      157.       ret->comp = c;
      158. >     ret->num_alloc = MIN_NODES;
      159.       return (ret);
      160.   

crypto/stack/stack.c:159:5: 
      157.       ret->comp = c;
      158.       ret->num_alloc = MIN_NODES;
      159. >     return (ret);
      160.   
      161.    err:

crypto/stack/stack.c:164:1: return from a call to sk_new
      162.       OPENSSL_free(ret);
      163.       return (NULL);
      164. > }
      165.   
      166.   int sk_insert(_STACK *st, void *data, int loc)

crypto/stack/stack.c:147:1: return from a call to sk_new_null
    145.   {
    146.       return sk_new((int (*)(const void *, const void *))0);
    147. > }
    148.   
    149.   _STACK *sk_new(int (*c) (const void *, const void *))

include/openssl/asn1t.h:966:1: return from a call to sk_ASN1_VALUE_new_null
  964.   DECLARE_ASN1_ITEM(ZLONG)
  965.   
  966. > DEFINE_STACK_OF(ASN1_VALUE)
  967.   
  968.   /* Functions used internally by the ASN1 code */

crypto/asn1/tasn_new.c:269:14: Taking false branch
267.           STACK_OF(ASN1_VALUE) *skval;
268.           skval = sk_ASN1_VALUE_new_null();
269.           if (!skval) {
                    ^
270.               ASN1err(ASN1_F_ASN1_TEMPLATE_NEW, ERR_R_MALLOC_FAILURE);
271.               ret = 0;

crypto/asn1/tasn_new.c:274:9: 
272.               goto done;
273.           }
274. >         *pval = (ASN1_VALUE *)skval;
275.           ret = 1;
276.           goto done;

crypto/asn1/tasn_new.c:275:9: 
273.           }
274.           *pval = (ASN1_VALUE *)skval;
275. >         ret = 1;
276.           goto done;
277.       }

crypto/asn1/tasn_new.c:280:2: 
278.       /* Otherwise pass it back to the item routine */
279.       ret = asn1_item_embed_new(pval, it, embed);
280. >  done:
281.   #ifndef OPENSSL_NO_CRYPTO_MDEBUG
282.       OPENSSL_mem_debug_pop();

crypto/asn1/tasn_new.c:284:5: 
282.       OPENSSL_mem_debug_pop();
283.   #endif
284. >     return ret;
285.   }
286.   

crypto/asn1/tasn_new.c:285:1: return from a call to asn1_template_new
283.   #endif
284.       return ret;
285. > }
286.   
287.   static void asn1_template_clear(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt)

static int asn1_template_new(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt)
{
    const ASN1_ITEM *it = ASN1_ITEM_ptr(tt->item);
    int embed = tt->flags & ASN1_TFLG_EMBED;
    ASN1_VALUE *tval;
    int ret;
    if (embed) {
        tval = (ASN1_VALUE *)pval;
        pval = &tval;
    }
    if (tt->flags & ASN1_TFLG_OPTIONAL) {
        asn1_template_clear(pval, tt);
        return 1;
    }
    if (tt->flags & ASN1_TFLG_ADB_MASK) {
        *pval = NULL;
        return 1;
    }
#ifndef OPENSSL_NO_CRYPTO_MDEBUG
    OPENSSL_mem_debug_push(tt->field_name
            ? tt->field_name : "asn1_template_new");
#endif
    if (tt->flags & ASN1_TFLG_SK_MASK) {
        STACK_OF(ASN1_VALUE) *skval;
        skval = sk_ASN1_VALUE_new_null();
        if (!skval) {
            ASN1err(ASN1_F_ASN1_TEMPLATE_NEW, ERR_R_MALLOC_FAILURE);
            ret = 0;
            goto done;
        }
        *pval = (ASN1_VALUE *)skval;
        ret = 1;
        goto done;
    }
    ret = asn1_item_embed_new(pval, it, embed);
 done:
#ifndef OPENSSL_NO_CRYPTO_MDEBUG
    OPENSSL_mem_debug_pop();
#endif
    return ret;
}
['static int asn1_template_new(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt)\n{\n    const ASN1_ITEM *it = ASN1_ITEM_ptr(tt->item);\n    int embed = tt->flags & ASN1_TFLG_EMBED;\n    ASN1_VALUE *tval;\n    int ret;\n    if (embed) {\n        tval = (ASN1_VALUE *)pval;\n        pval = &tval;\n    }\n    if (tt->flags & ASN1_TFLG_OPTIONAL) {\n        asn1_template_clear(pval, tt);\n        return 1;\n    }\n    if (tt->flags & ASN1_TFLG_ADB_MASK) {\n        *pval = NULL;\n        return 1;\n    }\n#ifndef OPENSSL_NO_CRYPTO_MDEBUG\n    OPENSSL_mem_debug_push(tt->field_name\n            ? tt->field_name : "asn1_template_new");\n#endif\n    if (tt->flags & ASN1_TFLG_SK_MASK) {\n        STACK_OF(ASN1_VALUE) *skval;\n        skval = sk_ASN1_VALUE_new_null();\n        if (!skval) {\n            ASN1err(ASN1_F_ASN1_TEMPLATE_NEW, ERR_R_MALLOC_FAILURE);\n            ret = 0;\n            goto done;\n        }\n        *pval = (ASN1_VALUE *)skval;\n        ret = 1;\n        goto done;\n    }\n    ret = asn1_item_embed_new(pval, it, embed);\n done:\n#ifndef OPENSSL_NO_CRYPTO_MDEBUG\n    OPENSSL_mem_debug_pop();\n#endif\n    return ret;\n}', 'DEFINE_STACK_OF(ASN1_VALUE)', '_STACK *sk_new_null(void)\n{\n    return sk_new((int (*)(const void *, const void *))0);\n}', '_STACK *sk_new(int (*c) (const void *, const void *))\n{\n    _STACK *ret;\n    if ((ret = OPENSSL_zalloc(sizeof(_STACK))) == NULL)\n        goto err;\n    if ((ret->data = OPENSSL_zalloc(sizeof(*ret->data) * MIN_NODES)) == NULL)\n        goto err;\n    ret->comp = c;\n    ret->num_alloc = MIN_NODES;\n    return (ret);\n err:\n    OPENSSL_free(ret);\n    return (NULL);\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}']