apps/crl2p7.c:159: error: USE_AFTER_FREE
  call to `sk_OPENSSL_STRING_free()` eventually accesses memory that was invalidated by call to `free()` on line 87 indirectly during the call to `sk_OPENSSL_STRING_push()`.
Showing all 24 steps of the trace


apps/crl2p7.c:85:32: invalidation part of the trace starts here
83.           case OPT_CERTFILE:
84.               if ((certflst == NULL)
85.                   && (certflst = sk_OPENSSL_STRING_new_null()) == NULL)
                                     ^
86.                   goto end;
87.               if (!sk_OPENSSL_STRING_push(certflst, opt_arg()))

apps/crl2p7.c:85:32: passed as argument to `sk_OPENSSL_STRING_new_null`
  83.           case OPT_CERTFILE:
  84.               if ((certflst == NULL)
  85.                   && (certflst = sk_OPENSSL_STRING_new_null()) == NULL)
                                       ^
  86.                   goto end;
  87.               if (!sk_OPENSSL_STRING_push(certflst, opt_arg()))

apps/crl2p7.c:85:32: return from call to `sk_OPENSSL_STRING_new_null`
  83.           case OPT_CERTFILE:
  84.               if ((certflst == NULL)
  85.                   && (certflst = sk_OPENSSL_STRING_new_null()) == NULL)
                                       ^
  86.                   goto end;
  87.               if (!sk_OPENSSL_STRING_push(certflst, opt_arg()))

apps/crl2p7.c:85:21: assigned
  83.           case OPT_CERTFILE:
  84.               if ((certflst == NULL)
  85.                   && (certflst = sk_OPENSSL_STRING_new_null()) == NULL)
                            ^
  86.                   goto end;
  87.               if (!sk_OPENSSL_STRING_push(certflst, opt_arg()))

apps/crl2p7.c:87:18: when calling `sk_OPENSSL_STRING_push` here
  85.                   && (certflst = sk_OPENSSL_STRING_new_null()) == NULL)
  86.                   goto end;
  87.               if (!sk_OPENSSL_STRING_push(certflst, opt_arg()))
                         ^
  88.                   goto end;
  89.               break;

include/openssl/safestack.h:155:1: parameter `sk` of sk_OPENSSL_STRING_push
    153.    * dealt with in the autogenerated macros below.
    154.    */
    155. > DEFINE_SPECIAL_STACK_OF(OPENSSL_STRING, char)
    156.   DEFINE_SPECIAL_STACK_OF_CONST(OPENSSL_CSTRING, char)
    157.   

include/openssl/safestack.h:155:1: when calling `OPENSSL_sk_push` here
    153.    * dealt with in the autogenerated macros below.
    154.    */
    155. > DEFINE_SPECIAL_STACK_OF(OPENSSL_STRING, char)
    156.   DEFINE_SPECIAL_STACK_OF_CONST(OPENSSL_CSTRING, char)
    157.   

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

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

crypto/stack/stack.c:216:1: parameter `st` of OPENSSL_sk_insert
        214.   }
        215.   
        216. > int OPENSSL_sk_insert(OPENSSL_STACK *st, const void *data, int loc)
        217.   {
        218.       if (st == NULL || st->num == max_nodes)

crypto/stack/stack.c:221:10: when calling `sk_reserve` here
        219.           return 0;
        220.   
        221.       if (!sk_reserve(st, 1, 0))
                        ^
        222.           return 0;
        223.   

crypto/stack/stack.c:160:1: parameter `st` of sk_reserve
          158.   
          159.   /* internal STACK storage allocation */
          160. > static int sk_reserve(OPENSSL_STACK *st, int n, int exact)
          161.   {
          162.       const void **tmpdata;

crypto/stack/stack.c:197:15: when calling `CRYPTO_realloc` here
          195.       }
          196.   
          197.       tmpdata = OPENSSL_realloc((void *)st->data, sizeof(void *) * num_alloc);
                               ^
          198.       if (tmpdata == NULL)
          199.           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.   }

apps/crl2p7.c:85:32: use-after-lifetime part of the trace starts here
83.           case OPT_CERTFILE:
84.               if ((certflst == NULL)
85.                   && (certflst = sk_OPENSSL_STRING_new_null()) == NULL)
                                     ^
86.                   goto end;
87.               if (!sk_OPENSSL_STRING_push(certflst, opt_arg()))

apps/crl2p7.c:85:32: passed as argument to `sk_OPENSSL_STRING_new_null`
  83.           case OPT_CERTFILE:
  84.               if ((certflst == NULL)
  85.                   && (certflst = sk_OPENSSL_STRING_new_null()) == NULL)
                                       ^
  86.                   goto end;
  87.               if (!sk_OPENSSL_STRING_push(certflst, opt_arg()))

apps/crl2p7.c:85:32: return from call to `sk_OPENSSL_STRING_new_null`
  83.           case OPT_CERTFILE:
  84.               if ((certflst == NULL)
  85.                   && (certflst = sk_OPENSSL_STRING_new_null()) == NULL)
                                       ^
  86.                   goto end;
  87.               if (!sk_OPENSSL_STRING_push(certflst, opt_arg()))

apps/crl2p7.c:85:21: assigned
  83.           case OPT_CERTFILE:
  84.               if ((certflst == NULL)
  85.                   && (certflst = sk_OPENSSL_STRING_new_null()) == NULL)
                            ^
  86.                   goto end;
  87.               if (!sk_OPENSSL_STRING_push(certflst, opt_arg()))

apps/crl2p7.c:159:5: when calling `sk_OPENSSL_STRING_free` here
  157.       ret = 0;
  158.    end:
  159.       sk_OPENSSL_STRING_free(certflst);
             ^
  160.       BIO_free(in);
  161.       BIO_free_all(out);

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.   }
