crypto/x509v3/pcy_tree.c:359: error: MEMORY_LEAK
  memory dynamically allocated by call to `policy_data_new()` at line 352, column 12 is not reachable after line 359, column 10.
Showing all 82 steps of the trace


crypto/x509v3/pcy_tree.c:340:1: start of procedure tree_add_unmatched()
338.    */
339.   
340. > static int tree_add_unmatched(X509_POLICY_LEVEL *curr,
341.                                 const X509_POLICY_CACHE *cache,
342.                                 const ASN1_OBJECT *id,

crypto/x509v3/pcy_tree.c:346:9: Taking false branch
344.   {
345.       X509_POLICY_DATA *data;
346.       if (id == NULL)
               ^
347.           id = node->data->valid_policy;
348.       /*

crypto/x509v3/pcy_tree.c:352:5: 
350.        * node.
351.        */
352. >     data = policy_data_new(NULL, id, node_critical(node));
353.   
354.       if (data == NULL)

crypto/x509v3/pcy_data.c:87:1: start of procedure policy_data_new()
  85.    */
  86.   
  87. > X509_POLICY_DATA *policy_data_new(POLICYINFO *policy,
  88.                                     const ASN1_OBJECT *cid, int crit)
  89.   {

crypto/x509v3/pcy_data.c:92:10: Taking true branch
  90.       X509_POLICY_DATA *ret;
  91.       ASN1_OBJECT *id;
  92.       if (!policy && !cid)
                 ^
  93.           return NULL;
  94.       if (cid) {

crypto/x509v3/pcy_data.c:92:21: Taking false branch
  90.       X509_POLICY_DATA *ret;
  91.       ASN1_OBJECT *id;
  92.       if (!policy && !cid)
                            ^
  93.           return NULL;
  94.       if (cid) {

crypto/x509v3/pcy_data.c:94:9: Taking true branch
  92.       if (!policy && !cid)
  93.           return NULL;
  94.       if (cid) {
                ^
  95.           id = OBJ_dup(cid);
  96.           if (!id)

crypto/x509v3/pcy_data.c:95:9: Skipping OBJ_dup(): empty list of specs
  93.           return NULL;
  94.       if (cid) {
  95.           id = OBJ_dup(cid);
                ^
  96.           if (!id)
  97.               return NULL;

crypto/x509v3/pcy_data.c:96:14: Taking false branch
  94.       if (cid) {
  95.           id = OBJ_dup(cid);
  96.           if (!id)
                     ^
  97.               return NULL;
  98.       } else

crypto/x509v3/pcy_data.c:100:5: 
  98.       } else
  99.           id = NULL;
  100. >     ret = OPENSSL_zalloc(sizeof(*ret));
  101.       if (ret == NULL)
  102.           return 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/x509v3/pcy_data.c:101:9: Taking false branch
  99.           id = NULL;
  100.       ret = OPENSSL_zalloc(sizeof(*ret));
  101.       if (ret == NULL)
                 ^
  102.           return NULL;
  103.       ret->expected_policy_set = sk_ASN1_OBJECT_new_null();

crypto/x509v3/pcy_data.c:103:5: 
  101.       if (ret == NULL)
  102.           return NULL;
  103. >     ret->expected_policy_set = sk_ASN1_OBJECT_new_null();
  104.       if (ret->expected_policy_set == NULL) {
  105.           OPENSSL_free(ret);

include/openssl/asn1.h:568:1: start of procedure sk_ASN1_OBJECT_new_null()
    566.   DECLARE_ASN1_ITEM(ASN1_OBJECT)
    567.   
    568. > DEFINE_STACK_OF(ASN1_OBJECT)
    569.   
    570.   ASN1_STRING *ASN1_STRING_new(void);

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/asn1.h:568:1: return from a call to sk_ASN1_OBJECT_new_null
    566.   DECLARE_ASN1_ITEM(ASN1_OBJECT)
    567.   
    568. > DEFINE_STACK_OF(ASN1_OBJECT)
    569.   
    570.   ASN1_STRING *ASN1_STRING_new(void);

crypto/x509v3/pcy_data.c:104:9: Taking false branch
  102.           return NULL;
  103.       ret->expected_policy_set = sk_ASN1_OBJECT_new_null();
  104.       if (ret->expected_policy_set == NULL) {
                 ^
  105.           OPENSSL_free(ret);
  106.           ASN1_OBJECT_free(id);

crypto/x509v3/pcy_data.c:110:9: Taking false branch
  108.       }
  109.   
  110.       if (crit)
                 ^
  111.           ret->flags = POLICY_DATA_FLAG_CRITICAL;
  112.   

crypto/x509v3/pcy_data.c:113:9: Taking true branch
  111.           ret->flags = POLICY_DATA_FLAG_CRITICAL;
  112.   
  113.       if (id)
                 ^
  114.           ret->valid_policy = id;
  115.       else {

crypto/x509v3/pcy_data.c:114:9: 
  112.   
  113.       if (id)
  114. >         ret->valid_policy = id;
  115.       else {
  116.           ret->valid_policy = policy->policyid;

crypto/x509v3/pcy_data.c:120:9: Taking false branch
  118.       }
  119.   
  120.       if (policy) {
                 ^
  121.           ret->qualifier_set = policy->qualifiers;
  122.           policy->qualifiers = NULL;

crypto/x509v3/pcy_data.c:125:5: 
  123.       }
  124.   
  125. >     return ret;
  126.   }

crypto/x509v3/pcy_data.c:126:1: return from a call to policy_data_new
  124.   
  125.       return ret;
  126. > }

crypto/x509v3/pcy_tree.c:354:9: Taking false branch
352.       data = policy_data_new(NULL, id, node_critical(node));
353.   
354.       if (data == NULL)
               ^
355.           return 0;
356.       /* Curr may not have anyPolicy */

crypto/x509v3/pcy_tree.c:357:5: 
355.           return 0;
356.       /* Curr may not have anyPolicy */
357. >     data->qualifier_set = cache->anyPolicy->qualifier_set;
358.       data->flags |= POLICY_DATA_FLAG_SHARED_QUALIFIERS;
359.       if (!level_add_node(curr, data, node, tree)) {

crypto/x509v3/pcy_tree.c:358:5: 
356.       /* Curr may not have anyPolicy */
357.       data->qualifier_set = cache->anyPolicy->qualifier_set;
358. >     data->flags |= POLICY_DATA_FLAG_SHARED_QUALIFIERS;
359.       if (!level_add_node(curr, data, node, tree)) {
360.           policy_data_free(data);

crypto/x509v3/pcy_tree.c:359:10: Skipping level_add_node(): empty list of specs
357.       data->qualifier_set = cache->anyPolicy->qualifier_set;
358.       data->flags |= POLICY_DATA_FLAG_SHARED_QUALIFIERS;
359.       if (!level_add_node(curr, data, node, tree)) {
                ^
360.           policy_data_free(data);
361.           return 0;

static int tree_add_unmatched(X509_POLICY_LEVEL *curr,
                              const X509_POLICY_CACHE *cache,
                              const ASN1_OBJECT *id,
                              X509_POLICY_NODE *node, X509_POLICY_TREE *tree)
{
    X509_POLICY_DATA *data;
    if (id == NULL)
        id = node->data->valid_policy;
    data = policy_data_new(NULL, id, node_critical(node));
    if (data == NULL)
        return 0;
    data->qualifier_set = cache->anyPolicy->qualifier_set;
    data->flags |= POLICY_DATA_FLAG_SHARED_QUALIFIERS;
    if (!level_add_node(curr, data, node, tree)) {
        policy_data_free(data);
        return 0;
    }
    return 1;
}
['static int tree_add_unmatched(X509_POLICY_LEVEL *curr,\n                              const X509_POLICY_CACHE *cache,\n                              const ASN1_OBJECT *id,\n                              X509_POLICY_NODE *node, X509_POLICY_TREE *tree)\n{\n    X509_POLICY_DATA *data;\n    if (id == NULL)\n        id = node->data->valid_policy;\n    data = policy_data_new(NULL, id, node_critical(node));\n    if (data == NULL)\n        return 0;\n    data->qualifier_set = cache->anyPolicy->qualifier_set;\n    data->flags |= POLICY_DATA_FLAG_SHARED_QUALIFIERS;\n    if (!level_add_node(curr, data, node, tree)) {\n        policy_data_free(data);\n        return 0;\n    }\n    return 1;\n}', 'X509_POLICY_DATA *policy_data_new(POLICYINFO *policy,\n                                  const ASN1_OBJECT *cid, int crit)\n{\n    X509_POLICY_DATA *ret;\n    ASN1_OBJECT *id;\n    if (!policy && !cid)\n        return NULL;\n    if (cid) {\n        id = OBJ_dup(cid);\n        if (!id)\n            return NULL;\n    } else\n        id = NULL;\n    ret = OPENSSL_zalloc(sizeof(*ret));\n    if (ret == NULL)\n        return NULL;\n    ret->expected_policy_set = sk_ASN1_OBJECT_new_null();\n    if (ret->expected_policy_set == NULL) {\n        OPENSSL_free(ret);\n        ASN1_OBJECT_free(id);\n        return NULL;\n    }\n    if (crit)\n        ret->flags = POLICY_DATA_FLAG_CRITICAL;\n    if (id)\n        ret->valid_policy = id;\n    else {\n        ret->valid_policy = policy->policyid;\n        policy->policyid = NULL;\n    }\n    if (policy) {\n        ret->qualifier_set = policy->qualifiers;\n        policy->qualifiers = NULL;\n    }\n    return ret;\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}', 'DEFINE_STACK_OF(ASN1_OBJECT)', '_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}']