crypto/x509v3/v3_pci.c:146: error: USE_AFTER_FREE
  call to `CRYPTO_free()` eventually accesses memory that was invalidated by call to `free()` on line 132 indirectly during the call to `CRYPTO_realloc()`.
Showing all 16 steps of the trace


crypto/x509v3/v3_pci.c:113:23: invalidation part of the trace starts here
111.           long val_len;
112.           if (!*policy) {
113.               *policy = ASN1_OCTET_STRING_new();
                             ^
114.               if (*policy == NULL) {
115.                   X509V3err(X509V3_F_PROCESS_PCI_VALUE, ERR_R_MALLOC_FAILURE);

crypto/x509v3/v3_pci.c:113:23: passed as argument to `ASN1_OCTET_STRING_new`
  111.           long val_len;
  112.           if (!*policy) {
  113.               *policy = ASN1_OCTET_STRING_new();
                               ^
  114.               if (*policy == NULL) {
  115.                   X509V3err(X509V3_F_PROCESS_PCI_VALUE, ERR_R_MALLOC_FAILURE);

crypto/x509v3/v3_pci.c:113:23: return from call to `ASN1_OCTET_STRING_new`
  111.           long val_len;
  112.           if (!*policy) {
  113.               *policy = ASN1_OCTET_STRING_new();
                               ^
  114.               if (*policy == NULL) {
  115.                   X509V3err(X509V3_F_PROCESS_PCI_VALUE, ERR_R_MALLOC_FAILURE);

crypto/x509v3/v3_pci.c:113:13: assigned
  111.           long val_len;
  112.           if (!*policy) {
  113.               *policy = ASN1_OCTET_STRING_new();
                     ^
  114.               if (*policy == NULL) {
  115.                   X509V3err(X509V3_F_PROCESS_PCI_VALUE, ERR_R_MALLOC_FAILURE);

crypto/x509v3/v3_pci.c:132:24: when calling `CRYPTO_realloc` here
  130.               }
  131.   
  132.               tmp_data = OPENSSL_realloc((*policy)->data,
                                ^
  133.                                          (*policy)->length + val_len + 1);
  134.               if (tmp_data) {

crypto/mem.c:166:1: parameter `str` of 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:172:9: when calling `CRYPTO_free` here
    170.   
    171.       if (num == 0) {
    172.           CRYPTO_free(str);
                   ^
    173.           return NULL;
    174.       }

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

crypto/mem.c:245:5: was invalidated by call to `free()`
      243.       }
      244.   #else
      245.       free(str);
                 ^
      246.   #endif
      247.   }

crypto/x509v3/v3_pci.c:113:23: use-after-lifetime part of the trace starts here
111.           long val_len;
112.           if (!*policy) {
113.               *policy = ASN1_OCTET_STRING_new();
                             ^
114.               if (*policy == NULL) {
115.                   X509V3err(X509V3_F_PROCESS_PCI_VALUE, ERR_R_MALLOC_FAILURE);

crypto/x509v3/v3_pci.c:113:23: passed as argument to `ASN1_OCTET_STRING_new`
  111.           long val_len;
  112.           if (!*policy) {
  113.               *policy = ASN1_OCTET_STRING_new();
                               ^
  114.               if (*policy == NULL) {
  115.                   X509V3err(X509V3_F_PROCESS_PCI_VALUE, ERR_R_MALLOC_FAILURE);

crypto/x509v3/v3_pci.c:113:23: return from call to `ASN1_OCTET_STRING_new`
  111.           long val_len;
  112.           if (!*policy) {
  113.               *policy = ASN1_OCTET_STRING_new();
                               ^
  114.               if (*policy == NULL) {
  115.                   X509V3err(X509V3_F_PROCESS_PCI_VALUE, ERR_R_MALLOC_FAILURE);

crypto/x509v3/v3_pci.c:113:13: assigned
  111.           long val_len;
  112.           if (!*policy) {
  113.               *policy = ASN1_OCTET_STRING_new();
                     ^
  114.               if (*policy == NULL) {
  115.                   X509V3err(X509V3_F_PROCESS_PCI_VALUE, ERR_R_MALLOC_FAILURE);

crypto/x509v3/v3_pci.c:146:17: when calling `CRYPTO_free` here
  144.                    * too!
  145.                    */
  146.                   OPENSSL_free((*policy)->data);
                         ^
  147.                   (*policy)->data = NULL;
  148.                   (*policy)->length = 0;

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

crypto/mem.c:245:5: invalid access occurs here
    243.       }
    244.   #else
    245.       free(str);
               ^
    246.   #endif
    247.   }
