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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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