crypto/asn1/asn1_lib.c:265: error: USE_AFTER_FREE
  call to `ASN1_STRING_free()` eventually accesses memory that was invalidated by call to `free()` on line 264 indirectly during the call to `ASN1_STRING_copy()`.
Showing all 29 steps of the trace


crypto/asn1/asn1_lib.c:261:11: invalidation part of the trace starts here
259.       if (!str)
260.           return NULL;
261.       ret = ASN1_STRING_new();
                 ^
262.       if (ret == NULL)
263.           return NULL;

crypto/asn1/asn1_lib.c:261:11: passed as argument to `ASN1_STRING_new`
  259.       if (!str)
  260.           return NULL;
  261.       ret = ASN1_STRING_new();
                   ^
  262.       if (ret == NULL)
  263.           return NULL;

crypto/asn1/asn1_lib.c:261:11: return from call to `ASN1_STRING_new`
  259.       if (!str)
  260.           return NULL;
  261.       ret = ASN1_STRING_new();
                   ^
  262.       if (ret == NULL)
  263.           return NULL;

crypto/asn1/asn1_lib.c:261:5: assigned
  259.       if (!str)
  260.           return NULL;
  261.       ret = ASN1_STRING_new();
             ^
  262.       if (ret == NULL)
  263.           return NULL;

crypto/asn1/asn1_lib.c:264:10: when calling `ASN1_STRING_copy` here
  262.       if (ret == NULL)
  263.           return NULL;
  264.       if (!ASN1_STRING_copy(ret, str)) {
                  ^
  265.           ASN1_STRING_free(ret);
  266.           return NULL;

crypto/asn1/asn1_lib.c:243:1: parameter `dst` of ASN1_STRING_copy
    241.   }
    242.   
    243. > int ASN1_STRING_copy(ASN1_STRING *dst, const ASN1_STRING *str)
    244.   {
    245.       if (str == NULL)

crypto/asn1/asn1_lib.c:248:10: when calling `ASN1_STRING_set` here
    246.           return 0;
    247.       dst->type = str->type;
    248.       if (!ASN1_STRING_set(dst, str->data, str->length))
                    ^
    249.           return 0;
    250.       /* Copy flags but preserve embed value */

crypto/asn1/asn1_lib.c:271:1: parameter `str` of ASN1_STRING_set
      269.   }
      270.   
      271. > int ASN1_STRING_set(ASN1_STRING *str, const void *_data, int len)
      272.   {
      273.       unsigned char *c;

crypto/asn1/asn1_lib.c:283:9: assigned
      281.       }
      282.       if ((str->length <= len) || (str->data == NULL)) {
      283.           c = str->data;
                     ^
      284.           str->data = OPENSSL_realloc(c, len + 1);
      285.           if (str->data == NULL) {

crypto/asn1/asn1_lib.c:284:21: when calling `CRYPTO_realloc` here
      282.       if ((str->length <= len) || (str->data == NULL)) {
      283.           c = str->data;
      284.           str->data = OPENSSL_realloc(c, len + 1);
                                 ^
      285.           if (str->data == NULL) {
      286.               ASN1err(ASN1_F_ASN1_STRING_SET, ERR_R_MALLOC_FAILURE);

crypto/mem.c:238:1: parameter `str` of CRYPTO_realloc
        236.   }
        237.   
        238. > void *CRYPTO_realloc(void *str, size_t num, const char *file, int line)
        239.   {
        240.       INCREMENT(realloc_count);

crypto/mem.c:249:9: when calling `CRYPTO_free` here
        247.   
        248.       if (num == 0) {
        249.           CRYPTO_free(str, file, line);
                       ^
        250.           return NULL;
        251.       }

crypto/mem.c:295:1: parameter `str` of CRYPTO_free
          293.   }
          294.   
          295. > void CRYPTO_free(void *str, const char *file, int line)
          296.   {
          297.       INCREMENT(free_count);

crypto/mem.c:312:5: was invalidated by call to `free()`
          310.       }
          311.   #else
          312.       free(str);
                     ^
          313.   #endif
          314.   }

crypto/asn1/asn1_lib.c:261:11: use-after-lifetime part of the trace starts here
259.       if (!str)
260.           return NULL;
261.       ret = ASN1_STRING_new();
                 ^
262.       if (ret == NULL)
263.           return NULL;

crypto/asn1/asn1_lib.c:261:11: passed as argument to `ASN1_STRING_new`
  259.       if (!str)
  260.           return NULL;
  261.       ret = ASN1_STRING_new();
                   ^
  262.       if (ret == NULL)
  263.           return NULL;

crypto/asn1/asn1_lib.c:261:11: return from call to `ASN1_STRING_new`
  259.       if (!str)
  260.           return NULL;
  261.       ret = ASN1_STRING_new();
                   ^
  262.       if (ret == NULL)
  263.           return NULL;

crypto/asn1/asn1_lib.c:261:5: assigned
  259.       if (!str)
  260.           return NULL;
  261.       ret = ASN1_STRING_new();
             ^
  262.       if (ret == NULL)
  263.           return NULL;

crypto/asn1/asn1_lib.c:264:10: passed as argument to `ASN1_STRING_copy`
  262.       if (ret == NULL)
  263.           return NULL;
  264.       if (!ASN1_STRING_copy(ret, str)) {
                  ^
  265.           ASN1_STRING_free(ret);
  266.           return NULL;

crypto/asn1/asn1_lib.c:243:1: parameter `dst` of ASN1_STRING_copy
    241.   }
    242.   
    243. > int ASN1_STRING_copy(ASN1_STRING *dst, const ASN1_STRING *str)
    244.   {
    245.       if (str == NULL)

crypto/asn1/asn1_lib.c:248:10: passed as argument to `ASN1_STRING_set`
    246.           return 0;
    247.       dst->type = str->type;
    248.       if (!ASN1_STRING_set(dst, str->data, str->length))
                    ^
    249.           return 0;
    250.       /* Copy flags but preserve embed value */

crypto/asn1/asn1_lib.c:271:1: parameter `str` of ASN1_STRING_set
      269.   }
      270.   
      271. > int ASN1_STRING_set(ASN1_STRING *str, const void *_data, int len)
      272.   {
      273.       unsigned char *c;

crypto/asn1/asn1_lib.c:283:9: assigned
      281.       }
      282.       if ((str->length <= len) || (str->data == NULL)) {
      283.           c = str->data;
                     ^
      284.           str->data = OPENSSL_realloc(c, len + 1);
      285.           if (str->data == NULL) {

crypto/asn1/asn1_lib.c:287:13: assigned
      285.           if (str->data == NULL) {
      286.               ASN1err(ASN1_F_ASN1_STRING_SET, ERR_R_MALLOC_FAILURE);
      287.               str->data = c;
                         ^
      288.               return 0;
      289.           }

crypto/asn1/asn1_lib.c:248:10: return from call to `ASN1_STRING_set`
    246.           return 0;
    247.       dst->type = str->type;
    248.       if (!ASN1_STRING_set(dst, str->data, str->length))
                    ^
    249.           return 0;
    250.       /* Copy flags but preserve embed value */

crypto/asn1/asn1_lib.c:264:10: return from call to `ASN1_STRING_copy`
  262.       if (ret == NULL)
  263.           return NULL;
  264.       if (!ASN1_STRING_copy(ret, str)) {
                  ^
  265.           ASN1_STRING_free(ret);
  266.           return NULL;

crypto/asn1/asn1_lib.c:265:9: when calling `ASN1_STRING_free` here
  263.           return NULL;
  264.       if (!ASN1_STRING_copy(ret, str)) {
  265.           ASN1_STRING_free(ret);
                 ^
  266.           return NULL;
  267.       }

crypto/mem.c:295:1: parameter `str` of CRYPTO_free
    293.   }
    294.   
    295. > void CRYPTO_free(void *str, const char *file, int line)
    296.   {
    297.       INCREMENT(free_count);

crypto/mem.c:312:5: invalid access occurs here
    310.       }
    311.   #else
    312.       free(str);
               ^
    313.   #endif
    314.   }
