crypto/pkcs7/pk7_attr.c:162: error: MEMORY_LEAK
  memory dynamically allocated by call to `ASN1_OCTET_STRING_new()` at line 156, column 10 is not reachable after line 162, column 9.
Showing all 99 steps of the trace


crypto/pkcs7/pk7_attr.c:152:1: start of procedure PKCS7_add1_attrib_digest()
150.   }
151.   
152. > int PKCS7_add1_attrib_digest(PKCS7_SIGNER_INFO *si,
153.                                const unsigned char *md, int mdlen)
154.   {

crypto/pkcs7/pk7_attr.c:156:5: 
154.   {
155.       ASN1_OCTET_STRING *os;
156. >     os = ASN1_OCTET_STRING_new();
157.       if (os == NULL)
158.           return 0;

crypto/asn1/tasn_typ.c:77:1: start of procedure ASN1_OCTET_STRING_new()
  75.   }
  76.   
  77. > IMPLEMENT_ASN1_STRING_FUNCTIONS(ASN1_OCTET_STRING)
  78.   IMPLEMENT_ASN1_STRING_FUNCTIONS(ASN1_INTEGER)
  79.   IMPLEMENT_ASN1_STRING_FUNCTIONS(ASN1_ENUMERATED)

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/tasn_typ.c:77:1: return from a call to ASN1_OCTET_STRING_new
  75.   }
  76.   
  77. > IMPLEMENT_ASN1_STRING_FUNCTIONS(ASN1_OCTET_STRING)
  78.   IMPLEMENT_ASN1_STRING_FUNCTIONS(ASN1_INTEGER)
  79.   IMPLEMENT_ASN1_STRING_FUNCTIONS(ASN1_ENUMERATED)

crypto/pkcs7/pk7_attr.c:157:9: Taking false branch
155.       ASN1_OCTET_STRING *os;
156.       os = ASN1_OCTET_STRING_new();
157.       if (os == NULL)
               ^
158.           return 0;
159.       if (!ASN1_STRING_set(os, md, mdlen)

crypto/pkcs7/pk7_attr.c:159:10: 
157.       if (os == NULL)
158.           return 0;
159. >     if (!ASN1_STRING_set(os, md, mdlen)
160.           || !PKCS7_add_signed_attribute(si, NID_pkcs9_messageDigest,
161.                                          V_ASN1_OCTET_STRING, os)) {

crypto/asn1/asn1_lib.c:308:1: start of procedure ASN1_STRING_set()
  306.   }
  307.   
  308. > int ASN1_STRING_set(ASN1_STRING *str, const void *_data, int len)
  309.   {
  310.       unsigned char *c;

crypto/asn1/asn1_lib.c:311:5: 
  309.   {
  310.       unsigned char *c;
  311. >     const char *data = _data;
  312.   
  313.       if (len < 0) {

crypto/asn1/asn1_lib.c:313:9: Taking false branch
  311.       const char *data = _data;
  312.   
  313.       if (len < 0) {
                 ^
  314.           if (data == NULL)
  315.               return (0);

crypto/asn1/asn1_lib.c:319:10: Taking true branch
  317.               len = strlen(data);
  318.       }
  319.       if ((str->length < len) || (str->data == NULL)) {
                  ^
  320.           c = str->data;
  321.           str->data = OPENSSL_realloc(c, len + 1);

crypto/asn1/asn1_lib.c:320:9: 
  318.       }
  319.       if ((str->length < len) || (str->data == NULL)) {
  320. >         c = str->data;
  321.           str->data = OPENSSL_realloc(c, len + 1);
  322.           if (str->data == NULL) {

crypto/asn1/asn1_lib.c:321:9: 
  319.       if ((str->length < len) || (str->data == NULL)) {
  320.           c = str->data;
  321. >         str->data = OPENSSL_realloc(c, len + 1);
  322.           if (str->data == NULL) {
  323.               ASN1err(ASN1_F_ASN1_STRING_SET, ERR_R_MALLOC_FAILURE);

crypto/mem.c:166:1: start of procedure CRYPTO_realloc()
    164.   }
    165.   
    166. > void *CRYPTO_realloc(void *str, size_t num, const char *file, int line)
    167.   {
    168.       if (str == NULL)

crypto/mem.c:168:9: Taking false branch
    166.   void *CRYPTO_realloc(void *str, size_t num, const char *file, int line)
    167.   {
    168.       if (str == NULL)
                   ^
    169.           return CRYPTO_malloc(num, file, line);
    170.   

crypto/mem.c:171:9: Taking false branch
    169.           return CRYPTO_malloc(num, file, line);
    170.   
    171.       if (num == 0) {
                   ^
    172.           CRYPTO_free(str);
    173.           return NULL;

crypto/mem.c:176:5: 
    174.       }
    175.   
    176. >     allow_customize = 0;
    177.   #ifndef OPENSSL_NO_CRYPTO_MDEBUG
    178.       if (call_malloc_debug) {

crypto/mem.c:186:5: 
    184.       }
    185.   #else
    186. >     (void)file;
    187.       (void)line;
    188.   #endif

crypto/mem.c:187:5: 
    185.   #else
    186.       (void)file;
    187. >     (void)line;
    188.   #endif
    189.       return realloc(str, num);

crypto/mem.c:189:5: 
    187.       (void)line;
    188.   #endif
    189. >     return realloc(str, num);
    190.   
    191.   }

crypto/mem.c:191:1: return from a call to CRYPTO_realloc
    189.       return realloc(str, num);
    190.   
    191. > }
    192.   
    193.   void *CRYPTO_clear_realloc(void *str, size_t old_len, size_t num,

crypto/asn1/asn1_lib.c:322:13: Taking false branch
  320.           c = str->data;
  321.           str->data = OPENSSL_realloc(c, len + 1);
  322.           if (str->data == NULL) {
                     ^
  323.               ASN1err(ASN1_F_ASN1_STRING_SET, ERR_R_MALLOC_FAILURE);
  324.               str->data = c;

crypto/asn1/asn1_lib.c:328:5: 
  326.           }
  327.       }
  328. >     str->length = len;
  329.       if (data != NULL) {
  330.           memcpy(str->data, data, len);

crypto/asn1/asn1_lib.c:329:9: Taking true branch
  327.       }
  328.       str->length = len;
  329.       if (data != NULL) {
                 ^
  330.           memcpy(str->data, data, len);
  331.           /* an allowance for strings :-) */

crypto/asn1/asn1_lib.c:330:9: 
  328.       str->length = len;
  329.       if (data != NULL) {
  330. >         memcpy(str->data, data, len);
  331.           /* an allowance for strings :-) */
  332.           str->data[len] = '\0';

crypto/asn1/asn1_lib.c:332:9: 
  330.           memcpy(str->data, data, len);
  331.           /* an allowance for strings :-) */
  332. >         str->data[len] = '\0';
  333.       }
  334.       return (1);

crypto/asn1/asn1_lib.c:334:5: 
  332.           str->data[len] = '\0';
  333.       }
  334. >     return (1);
  335.   }
  336.   

crypto/asn1/asn1_lib.c:335:1: return from a call to ASN1_STRING_set
  333.       }
  334.       return (1);
  335. > }
  336.   
  337.   void ASN1_STRING_set0(ASN1_STRING *str, void *data, int len)

crypto/pkcs7/pk7_attr.c:159:10: Taking false branch
157.       if (os == NULL)
158.           return 0;
159.       if (!ASN1_STRING_set(os, md, mdlen)
                ^
160.           || !PKCS7_add_signed_attribute(si, NID_pkcs9_messageDigest,
161.                                          V_ASN1_OCTET_STRING, os)) {

crypto/pkcs7/pk7_attr.c:160:13: 
158.           return 0;
159.       if (!ASN1_STRING_set(os, md, mdlen)
160. >         || !PKCS7_add_signed_attribute(si, NID_pkcs9_messageDigest,
161.                                          V_ASN1_OCTET_STRING, os)) {
162.           ASN1_OCTET_STRING_free(os);

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,

crypto/pkcs7/pk7_attr.c:160:13: Taking true branch
158.           return 0;
159.       if (!ASN1_STRING_set(os, md, mdlen)
160.           || !PKCS7_add_signed_attribute(si, NID_pkcs9_messageDigest,
                   ^
161.                                          V_ASN1_OCTET_STRING, os)) {
162.           ASN1_OCTET_STRING_free(os);

crypto/pkcs7/pk7_attr.c:162:9: 
160.           || !PKCS7_add_signed_attribute(si, NID_pkcs9_messageDigest,
161.                                          V_ASN1_OCTET_STRING, os)) {
162. >         ASN1_OCTET_STRING_free(os);
163.           return 0;
164.       }

crypto/asn1/tasn_typ.c:77:1: start of procedure ASN1_OCTET_STRING_free()
  75.   }
  76.   
  77. > IMPLEMENT_ASN1_STRING_FUNCTIONS(ASN1_OCTET_STRING)
  78.   IMPLEMENT_ASN1_STRING_FUNCTIONS(ASN1_INTEGER)
  79.   IMPLEMENT_ASN1_STRING_FUNCTIONS(ASN1_ENUMERATED)

crypto/asn1/asn1_lib.c:362:1: start of procedure ASN1_STRING_free()
    360.   }
    361.   
    362. > void ASN1_STRING_free(ASN1_STRING *a)
    363.   {
    364.       if (a == NULL)

crypto/asn1/asn1_lib.c:364:9: Taking false branch
    362.   void ASN1_STRING_free(ASN1_STRING *a)
    363.   {
    364.       if (a == NULL)
                   ^
    365.           return;
    366.       if (!(a->flags & ASN1_STRING_FLAG_NDEF))

crypto/asn1/asn1_lib.c:366:11: Taking false branch
    364.       if (a == NULL)
    365.           return;
    366.       if (!(a->flags & ASN1_STRING_FLAG_NDEF))
                     ^
    367.           OPENSSL_free(a->data);
    368.       if (!(a->flags & ASN1_STRING_FLAG_EMBED))

crypto/asn1/asn1_lib.c:368:11: Taking false branch
    366.       if (!(a->flags & ASN1_STRING_FLAG_NDEF))
    367.           OPENSSL_free(a->data);
    368.       if (!(a->flags & ASN1_STRING_FLAG_EMBED))
                     ^
    369.           OPENSSL_free(a);
    370.   }

crypto/asn1/asn1_lib.c:368:5: 
    366.       if (!(a->flags & ASN1_STRING_FLAG_NDEF))
    367.           OPENSSL_free(a->data);
    368. >     if (!(a->flags & ASN1_STRING_FLAG_EMBED))
    369.           OPENSSL_free(a);
    370.   }

crypto/asn1/asn1_lib.c:370:1: return from a call to ASN1_STRING_free
    368.       if (!(a->flags & ASN1_STRING_FLAG_EMBED))
    369.           OPENSSL_free(a);
    370. > }
    371.   
    372.   void ASN1_STRING_clear_free(ASN1_STRING *a)

crypto/asn1/tasn_typ.c:77:1: return from a call to ASN1_OCTET_STRING_free
  75.   }
  76.   
  77. > IMPLEMENT_ASN1_STRING_FUNCTIONS(ASN1_OCTET_STRING)
  78.   IMPLEMENT_ASN1_STRING_FUNCTIONS(ASN1_INTEGER)
  79.   IMPLEMENT_ASN1_STRING_FUNCTIONS(ASN1_ENUMERATED)
