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


crypto/x509v3/pcy_tree.c:341:1: start of procedure tree_add_unmatched()
339.    * Return value: 1 on success, 0 otherwise.
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:348:9: Taking true branch
346.       X509_POLICY_DATA *data;
347.   
348.       if (id == NULL)
               ^
349.           id = node->data->valid_policy;
350.       /*

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

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

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 true branch
  108.       }
  109.   
  110.       if (crit)
                 ^
  111.           ret->flags = POLICY_DATA_FLAG_CRITICAL;
  112.   

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

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.        * node.
353.        */
354.       if ((data = policy_data_new(NULL, id, node_critical(node))) == NULL)
               ^
355.           return 0;
356.   

crypto/x509v3/pcy_tree.c:358:5: 
356.   
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) == NULL) {

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) == NULL) {
361.           policy_data_free(data);

crypto/x509v3/pcy_tree.c:360:9: 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) == NULL) {
               ^
361.           policy_data_free(data);
362.           return 0;

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