crypto/x509v3/pcy_tree.c:365: error: MEMORY_LEAK
  memory dynamically allocated to `return` by call to `policy_data_new()` at line 353, column 12 is not reachable after line 365, column 5.
Showing all 85 steps of the trace


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

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

crypto/x509v3/pcy_tree.c:348:9: 
346.       X509_POLICY_DATA *data;
347.       if (id == NULL)
348. >         id = node->data->valid_policy;
349.       /*
350.        * Create a new node with qualifiers from anyPolicy and id from unmatched

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

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

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

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

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

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

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

crypto/x509v3/pcy_data.c:101:5: 
  99.       } else
  100.           id = NULL;
  101. >     ret = OPENSSL_zalloc(sizeof(*ret));
  102.       if (ret == NULL)
  103.           return NULL;

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

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

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

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

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

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

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

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.   #ifdef 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/stack/stack.c:154:9: Taking false branch
        152.       _STACK *ret;
        153.   
        154.       if ((ret = OPENSSL_zalloc(sizeof(_STACK))) == NULL)
                       ^
        155.           goto err;
        156.       if ((ret->data = OPENSSL_zalloc(sizeof(*ret->data) * MIN_NODES)) == NULL)

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

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.   #ifdef 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/stack/stack.c:156:9: Taking false branch
        154.       if ((ret = OPENSSL_zalloc(sizeof(_STACK))) == NULL)
        155.           goto err;
        156.       if ((ret->data = OPENSSL_zalloc(sizeof(*ret->data) * MIN_NODES)) == NULL)
                       ^
        157.           goto err;
        158.       ret->comp = c;

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

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

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

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

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

include/openssl/asn1.h:569:1: return from a call to sk_ASN1_OBJECT_new_null
    567.   DECLARE_ASN1_ITEM(ASN1_OBJECT)
    568.   
    569. > DEFINE_STACK_OF(ASN1_OBJECT)
    570.   
    571.   ASN1_STRING *ASN1_STRING_new(void);

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

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

crypto/x509v3/pcy_data.c:112:9: 
  110.   
  111.       if (crit)
  112. >         ret->flags = POLICY_DATA_FLAG_CRITICAL;
  113.   
  114.       if (id)

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

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

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

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

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

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

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

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

crypto/x509v3/pcy_tree.c:360:10: Taking false branch
358.       data->qualifier_set = cache->anyPolicy->qualifier_set;
359.       data->flags |= POLICY_DATA_FLAG_SHARED_QUALIFIERS;
360.       if (!level_add_node(curr, data, node, tree)) {
                ^
361.           policy_data_free(data);
362.           return 0;

crypto/x509v3/pcy_tree.c:365:5: 
363.       }
364.   
365. >     return 1;
366.   }
367.   

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#ifdef 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}']