crypto/pkcs7/pk7_attr.c:80: error: MEMORY_LEAK
  memory dynamically allocated by call to `ASN1_STRING_new()` at line 74, column 16 is not reachable after line 80, column 5.
Showing all 76 steps of the trace


crypto/pkcs7/pk7_attr.c:69:1: start of procedure PKCS7_add_attrib_smimecap()
67.   #include <openssl/err.h>
68.   
69. > int PKCS7_add_attrib_smimecap(PKCS7_SIGNER_INFO *si,
70.                                 STACK_OF(X509_ALGOR) *cap)
71.   {

crypto/pkcs7/pk7_attr.c:74:9: 
72.       ASN1_STRING *seq;
73.   
74. >     if ((seq = ASN1_STRING_new()) == NULL) {
75.           PKCS7err(PKCS7_F_PKCS7_ADD_ATTRIB_SMIMECAP, ERR_R_MALLOC_FAILURE);
76.           return 0;

crypto/asn1/asn1_lib.c:343:1: start of procedure ASN1_STRING_new()
  341.   }
  342.   
  343. > ASN1_STRING *ASN1_STRING_new(void)
  344.   {
  345.       return (ASN1_STRING_type_new(V_ASN1_OCTET_STRING));

crypto/asn1/asn1_lib.c:345:5: 
  343.   ASN1_STRING *ASN1_STRING_new(void)
  344.   {
  345. >     return (ASN1_STRING_type_new(V_ASN1_OCTET_STRING));
  346.   }
  347.   

crypto/asn1/asn1_lib.c:348:1: start of procedure ASN1_STRING_type_new()
    346.   }
    347.   
    348. > ASN1_STRING *ASN1_STRING_type_new(int type)
    349.   {
    350.       ASN1_STRING *ret;

crypto/asn1/asn1_lib.c:352:5: 
    350.       ASN1_STRING *ret;
    351.   
    352. >     ret = OPENSSL_zalloc(sizeof(*ret));
    353.       if (ret == NULL) {
    354.           ASN1err(ASN1_F_ASN1_STRING_TYPE_NEW, ERR_R_MALLOC_FAILURE);

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/asn1/asn1_lib.c:353:9: Taking false branch
    351.   
    352.       ret = OPENSSL_zalloc(sizeof(*ret));
    353.       if (ret == NULL) {
                   ^
    354.           ASN1err(ASN1_F_ASN1_STRING_TYPE_NEW, ERR_R_MALLOC_FAILURE);
    355.           return (NULL);

crypto/asn1/asn1_lib.c:357:5: 
    355.           return (NULL);
    356.       }
    357. >     ret->type = type;
    358.       return (ret);
    359.   }

crypto/asn1/asn1_lib.c:358:5: 
    356.       }
    357.       ret->type = type;
    358. >     return (ret);
    359.   }
    360.   

crypto/asn1/asn1_lib.c:359:1: return from a call to ASN1_STRING_type_new
    357.       ret->type = type;
    358.       return (ret);
    359. > }
    360.   
    361.   void ASN1_STRING_free(ASN1_STRING *a)

crypto/asn1/asn1_lib.c:346:1: return from a call to ASN1_STRING_new
  344.   {
  345.       return (ASN1_STRING_type_new(V_ASN1_OCTET_STRING));
  346. > }
  347.   
  348.   ASN1_STRING *ASN1_STRING_type_new(int type)

crypto/pkcs7/pk7_attr.c:74:9: Taking false branch
72.       ASN1_STRING *seq;
73.   
74.       if ((seq = ASN1_STRING_new()) == NULL) {
              ^
75.           PKCS7err(PKCS7_F_PKCS7_ADD_ATTRIB_SMIMECAP, ERR_R_MALLOC_FAILURE);
76.           return 0;

crypto/pkcs7/pk7_attr.c:78:5: 
76.           return 0;
77.       }
78. >     seq->length = ASN1_item_i2d((ASN1_VALUE *)cap, &seq->data,
79.                                   ASN1_ITEM_rptr(X509_ALGORS));
80.       return PKCS7_add_signed_attribute(si, NID_SMIMECapabilities,

crypto/asn1/tasn_enc.c:91:1: start of procedure ASN1_item_i2d()
  89.   }
  90.   
  91. > int ASN1_item_i2d(ASN1_VALUE *val, unsigned char **out, const ASN1_ITEM *it)
  92.   {
  93.       return asn1_item_flags_i2d(val, out, it, 0);

crypto/asn1/tasn_enc.c:93:5: 
  91.   int ASN1_item_i2d(ASN1_VALUE *val, unsigned char **out, const ASN1_ITEM *it)
  92.   {
  93. >     return asn1_item_flags_i2d(val, out, it, 0);
  94.   }
  95.   

crypto/asn1/tasn_enc.c:103:1: start of procedure asn1_item_flags_i2d()
    101.    */
    102.   
    103. > static int asn1_item_flags_i2d(ASN1_VALUE *val, unsigned char **out,
    104.                                  const ASN1_ITEM *it, int flags)
    105.   {

crypto/asn1/tasn_enc.c:106:9: Taking true branch
    104.                                  const ASN1_ITEM *it, int flags)
    105.   {
    106.       if (out && !*out) {
                   ^
    107.           unsigned char *p, *buf;
    108.           int len;

crypto/asn1/tasn_enc.c:106:17: Taking false branch
    104.                                  const ASN1_ITEM *it, int flags)
    105.   {
    106.       if (out && !*out) {
                           ^
    107.           unsigned char *p, *buf;
    108.           int len;

crypto/asn1/tasn_enc.c:121:5: Skipping ASN1_item_ex_i2d(): empty list of specs
    119.       }
    120.   
    121.       return ASN1_item_ex_i2d(&val, out, it, -1, flags);
               ^
    122.   }
    123.   

crypto/asn1/tasn_enc.c:122:1: return from a call to asn1_item_flags_i2d
    120.   
    121.       return ASN1_item_ex_i2d(&val, out, it, -1, flags);
    122. > }
    123.   
    124.   /*

crypto/asn1/tasn_enc.c:94:1: return from a call to ASN1_item_i2d
  92.   {
  93.       return asn1_item_flags_i2d(val, out, it, 0);
  94. > }
  95.   
  96.   /*

crypto/pkcs7/pk7_attr.c:80:5: 
78.       seq->length = ASN1_item_i2d((ASN1_VALUE *)cap, &seq->data,
79.                                   ASN1_ITEM_rptr(X509_ALGORS));
80. >     return PKCS7_add_signed_attribute(si, NID_SMIMECapabilities,
81.                                         V_ASN1_SEQUENCE, seq);
82.   }

crypto/pkcs7/pk7_doit.c:1176:1: start of procedure PKCS7_add_signed_attribute()
  1174.   }
  1175.   
  1176. > int PKCS7_add_signed_attribute(PKCS7_SIGNER_INFO *p7si, int nid, int atrtype,
  1177.                                  void *value)
  1178.   {

crypto/pkcs7/pk7_doit.c:1179:5: 
  1177.                                  void *value)
  1178.   {
  1179. >     return (add_attribute(&(p7si->auth_attr), nid, atrtype, value));
  1180.   }
  1181.   

crypto/pkcs7/pk7_doit.c:1188:1: start of procedure add_attribute()
    1186.   }
    1187.   
    1188. > static int add_attribute(STACK_OF(X509_ATTRIBUTE) **sk, int nid, int atrtype,
    1189.                            void *value)
    1190.   {

crypto/pkcs7/pk7_doit.c:1191:5: 
    1189.                            void *value)
    1190.   {
    1191. >     X509_ATTRIBUTE *attr = NULL;
    1192.   
    1193.       if (*sk == NULL) {

crypto/pkcs7/pk7_doit.c:1193:9: Taking true branch
    1191.       X509_ATTRIBUTE *attr = NULL;
    1192.   
    1193.       if (*sk == NULL) {
                    ^
    1194.           if ((*sk = sk_X509_ATTRIBUTE_new_null()) == NULL)
    1195.               return 0;

crypto/pkcs7/pk7_doit.c:1194:13: 
    1192.   
    1193.       if (*sk == NULL) {
    1194. >         if ((*sk = sk_X509_ATTRIBUTE_new_null()) == NULL)
    1195.               return 0;
    1196.    new_attrib:

include/openssl/x509.h:159:1: start of procedure sk_X509_ATTRIBUTE_new_null()
      157.   typedef struct x509_attributes_st X509_ATTRIBUTE;
      158.   
      159. > DEFINE_STACK_OF(X509_ATTRIBUTE)
      160.   
      161.   typedef struct X509_req_info_st X509_REQ_INFO;

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 false 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: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 true 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:161:2: 
          159.       return (ret);
          160.   
          161. >  err:
          162.       OPENSSL_free(ret);
          163.       return (NULL);

crypto/stack/stack.c:162:5: 
          160.   
          161.    err:
          162. >     OPENSSL_free(ret);
          163.       return (NULL);
          164.   }

crypto/mem.c:233:1: start of procedure CRYPTO_free()
            231.   }
            232.   
            233. > void CRYPTO_free(void *str)
            234.   {
            235.   #ifndef OPENSSL_NO_CRYPTO_MDEBUG

crypto/mem.c:244:5: 
            242.       }
            243.   #else
            244. >     free(str);
            245.   #endif
            246.   }

crypto/mem.c:246:1: return from a call to CRYPTO_free
            244.       free(str);
            245.   #endif
            246. > }
            247.   
            248.   void CRYPTO_clear_free(void *str, size_t num)

crypto/stack/stack.c:163:5: 
          161.    err:
          162.       OPENSSL_free(ret);
          163. >     return (NULL);
          164.   }
          165.   

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/x509.h:159:1: return from a call to sk_X509_ATTRIBUTE_new_null
      157.   typedef struct x509_attributes_st X509_ATTRIBUTE;
      158.   
      159. > DEFINE_STACK_OF(X509_ATTRIBUTE)
      160.   
      161.   typedef struct X509_req_info_st X509_REQ_INFO;

crypto/pkcs7/pk7_doit.c:1194:13: Taking true branch
    1192.   
    1193.       if (*sk == NULL) {
    1194.           if ((*sk = sk_X509_ATTRIBUTE_new_null()) == NULL)
                        ^
    1195.               return 0;
    1196.    new_attrib:

crypto/pkcs7/pk7_doit.c:1195:13: 
    1193.       if (*sk == NULL) {
    1194.           if ((*sk = sk_X509_ATTRIBUTE_new_null()) == NULL)
    1195. >             return 0;
    1196.    new_attrib:
    1197.           if ((attr = X509_ATTRIBUTE_create(nid, atrtype, value)) == NULL)

crypto/pkcs7/pk7_doit.c:1224:1: return from a call to add_attribute
    1222.    end:
    1223.       return (1);
    1224. > }

crypto/pkcs7/pk7_doit.c:1180:1: return from a call to PKCS7_add_signed_attribute
  1178.   {
  1179.       return (add_attribute(&(p7si->auth_attr), nid, atrtype, value));
  1180. > }
  1181.   
  1182.   int PKCS7_add_attribute(PKCS7_SIGNER_INFO *p7si, int nid, int atrtype,
