test/crltest.c:294: error: USE_AFTER_FREE
  call to `sk_X509_CRL_push()` eventually accesses memory that was invalidated by call to `free()` on line 291 indirectly during the call to `sk_X509_CRL_push()`.
Showing all 24 steps of the trace


test/crltest.c:289:30: invalidation part of the trace starts here
287.   static STACK_OF(X509_CRL) *make_CRL_stack(X509_CRL *x1, X509_CRL *x2)
288.   {
289.       STACK_OF(X509_CRL) *sk = sk_X509_CRL_new_null();
                                    ^
290.   
291.       sk_X509_CRL_push(sk, x1);

test/crltest.c:289:30: passed as argument to `sk_X509_CRL_new_null`
  287.   static STACK_OF(X509_CRL) *make_CRL_stack(X509_CRL *x1, X509_CRL *x2)
  288.   {
  289.       STACK_OF(X509_CRL) *sk = sk_X509_CRL_new_null();
                                      ^
  290.   
  291.       sk_X509_CRL_push(sk, x1);

test/crltest.c:289:30: return from call to `sk_X509_CRL_new_null`
  287.   static STACK_OF(X509_CRL) *make_CRL_stack(X509_CRL *x1, X509_CRL *x2)
  288.   {
  289.       STACK_OF(X509_CRL) *sk = sk_X509_CRL_new_null();
                                      ^
  290.   
  291.       sk_X509_CRL_push(sk, x1);

test/crltest.c:289:5: assigned
  287.   static STACK_OF(X509_CRL) *make_CRL_stack(X509_CRL *x1, X509_CRL *x2)
  288.   {
  289.       STACK_OF(X509_CRL) *sk = sk_X509_CRL_new_null();
             ^
  290.   
  291.       sk_X509_CRL_push(sk, x1);

test/crltest.c:291:5: when calling `sk_X509_CRL_push` here
  289.       STACK_OF(X509_CRL) *sk = sk_X509_CRL_new_null();
  290.   
  291.       sk_X509_CRL_push(sk, x1);
             ^
  292.       X509_CRL_up_ref(x1);
  293.       if (x2 != NULL) {

include/openssl/x509.h:228:1: parameter `sk` of sk_X509_CRL_push
    226.   typedef struct X509_crl_info_st X509_CRL_INFO;
    227.   
    228. > DEFINE_STACK_OF(X509_CRL)
    229.   
    230.   typedef struct private_key_st {

include/openssl/x509.h:228:1: when calling `OPENSSL_sk_push` here
    226.   typedef struct X509_crl_info_st X509_CRL_INFO;
    227.   
    228. > DEFINE_STACK_OF(X509_CRL)
    229.   
    230.   typedef struct private_key_st {

crypto/stack/stack.c:307:1: parameter `st` of OPENSSL_sk_push
      305.   }
      306.   
      307. > int OPENSSL_sk_push(OPENSSL_STACK *st, const void *data)
      308.   {
      309.       if (st == NULL)

crypto/stack/stack.c:311:12: when calling `OPENSSL_sk_insert` here
      309.       if (st == NULL)
      310.           return -1;
      311.       return OPENSSL_sk_insert(st, data, st->num);
                        ^
      312.   }
      313.   

crypto/stack/stack.c:222:1: parameter `st` of OPENSSL_sk_insert
        220.   }
        221.   
        222. > int OPENSSL_sk_insert(OPENSSL_STACK *st, const void *data, int loc)
        223.   {
        224.       if (st == NULL || st->num < 0 || st->num == max_nodes)

crypto/stack/stack.c:227:10: when calling `sk_reserve` here
        225.           return 0;
        226.   
        227.       if (!sk_reserve(st, 1, 0))
                        ^
        228.           return 0;
        229.   

crypto/stack/stack.c:166:1: parameter `st` of sk_reserve
          164.   
          165.   /* internal STACK storage allocation */
          166. > static int sk_reserve(OPENSSL_STACK *st, int n, int exact)
          167.   {
          168.       const void **tmpdata;

crypto/stack/stack.c:203:15: when calling `CRYPTO_realloc` here
          201.       }
          202.   
          203.       tmpdata = OPENSSL_realloc((void *)st->data, sizeof(void *) * num_alloc);
                               ^
          204.       if (tmpdata == NULL)
          205.           return 0;

crypto/mem.c:208:1: parameter `str` of CRYPTO_realloc
            206.   }
            207.   
            208. > void *CRYPTO_realloc(void *str, size_t num, const char *file, int line)
            209.   {
            210.       if (realloc_impl != NULL && realloc_impl != &CRYPTO_realloc)

crypto/mem.c:218:9: when calling `CRYPTO_free` here
            216.   
            217.       if (num == 0) {
            218.           CRYPTO_free(str, file, line);
                           ^
            219.           return NULL;
            220.       }

crypto/mem.c:265:1: parameter `str` of CRYPTO_free
              263.   }
              264.   
              265. > void CRYPTO_free(void *str, const char *file, int line)
              266.   {
              267.       if (free_impl != NULL && free_impl != &CRYPTO_free) {

crypto/mem.c:281:5: was invalidated by call to `free()`
              279.       }
              280.   #else
              281.       free(str);
                         ^
              282.   #endif
              283.   }

test/crltest.c:289:30: use-after-lifetime part of the trace starts here
287.   static STACK_OF(X509_CRL) *make_CRL_stack(X509_CRL *x1, X509_CRL *x2)
288.   {
289.       STACK_OF(X509_CRL) *sk = sk_X509_CRL_new_null();
                                    ^
290.   
291.       sk_X509_CRL_push(sk, x1);

test/crltest.c:289:30: passed as argument to `sk_X509_CRL_new_null`
  287.   static STACK_OF(X509_CRL) *make_CRL_stack(X509_CRL *x1, X509_CRL *x2)
  288.   {
  289.       STACK_OF(X509_CRL) *sk = sk_X509_CRL_new_null();
                                      ^
  290.   
  291.       sk_X509_CRL_push(sk, x1);

test/crltest.c:289:30: return from call to `sk_X509_CRL_new_null`
  287.   static STACK_OF(X509_CRL) *make_CRL_stack(X509_CRL *x1, X509_CRL *x2)
  288.   {
  289.       STACK_OF(X509_CRL) *sk = sk_X509_CRL_new_null();
                                      ^
  290.   
  291.       sk_X509_CRL_push(sk, x1);

test/crltest.c:289:5: assigned
  287.   static STACK_OF(X509_CRL) *make_CRL_stack(X509_CRL *x1, X509_CRL *x2)
  288.   {
  289.       STACK_OF(X509_CRL) *sk = sk_X509_CRL_new_null();
             ^
  290.   
  291.       sk_X509_CRL_push(sk, x1);

test/crltest.c:294:9: when calling `sk_X509_CRL_push` here
  292.       X509_CRL_up_ref(x1);
  293.       if (x2 != NULL) {
  294.           sk_X509_CRL_push(sk, x2);
                 ^
  295.           X509_CRL_up_ref(x2);
  296.       }

crypto/mem.c:265:1: parameter `str` of CRYPTO_free
    263.   }
    264.   
    265. > void CRYPTO_free(void *str, const char *file, int line)
    266.   {
    267.       if (free_impl != NULL && free_impl != &CRYPTO_free) {

crypto/mem.c:281:5: invalid access occurs here
    279.       }
    280.   #else
    281.       free(str);
               ^
    282.   #endif
    283.   }
