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


apps/crl2p7.c:139:32: invalidation part of the trace starts here
137.           case OPT_CERTFILE:
138.               if ((certflst == NULL)
139.                   && (certflst = sk_OPENSSL_STRING_new_null()) == NULL)
                                      ^
140.                   goto end;
141.               if (!sk_OPENSSL_STRING_push(certflst, opt_arg())) {

apps/crl2p7.c:139:32: passed as argument to `sk_OPENSSL_STRING_new_null`
  137.           case OPT_CERTFILE:
  138.               if ((certflst == NULL)
  139.                   && (certflst = sk_OPENSSL_STRING_new_null()) == NULL)
                                        ^
  140.                   goto end;
  141.               if (!sk_OPENSSL_STRING_push(certflst, opt_arg())) {

apps/crl2p7.c:139:32: return from call to `sk_OPENSSL_STRING_new_null`
  137.           case OPT_CERTFILE:
  138.               if ((certflst == NULL)
  139.                   && (certflst = sk_OPENSSL_STRING_new_null()) == NULL)
                                        ^
  140.                   goto end;
  141.               if (!sk_OPENSSL_STRING_push(certflst, opt_arg())) {

apps/crl2p7.c:139:21: assigned
  137.           case OPT_CERTFILE:
  138.               if ((certflst == NULL)
  139.                   && (certflst = sk_OPENSSL_STRING_new_null()) == NULL)
                             ^
  140.                   goto end;
  141.               if (!sk_OPENSSL_STRING_push(certflst, opt_arg())) {

apps/crl2p7.c:141:18: when calling `sk_OPENSSL_STRING_push` here
  139.                   && (certflst = sk_OPENSSL_STRING_new_null()) == NULL)
  140.                   goto end;
  141.               if (!sk_OPENSSL_STRING_push(certflst, opt_arg())) {
                          ^
  142.                   sk_OPENSSL_STRING_free(certflst);
  143.                   goto end;

include/openssl/safestack.h:214:1: parameter `sk` of sk_OPENSSL_STRING_push
    212.    * dealt with in the autogenerated macros below.
    213.    */
    214. > DEFINE_SPECIAL_STACK_OF(OPENSSL_STRING, char)
    215.   
    216.   /*

include/openssl/safestack.h:214:1: when calling `sk_push` here
    212.    * dealt with in the autogenerated macros below.
    213.    */
    214. > DEFINE_SPECIAL_STACK_OF(OPENSSL_STRING, char)
    215.   
    216.   /*

crypto/stack/stack.c:259:1: parameter `st` of sk_push
      257.   }
      258.   
      259. > int sk_push(_STACK *st, void *data)
      260.   {
      261.       return (sk_insert(st, data, st->num));

crypto/stack/stack.c:261:13: when calling `sk_insert` here
      259.   int sk_push(_STACK *st, void *data)
      260.   {
      261.       return (sk_insert(st, data, st->num));
                         ^
      262.   }
      263.   

crypto/stack/stack.c:167:1: parameter `st` of sk_insert
        165.   }
        166.   
        167. > int sk_insert(_STACK *st, void *data, int loc)
        168.   {
        169.       char **s;

crypto/stack/stack.c:174:13: when calling `CRYPTO_realloc` here
        172.           return 0;
        173.       if (st->num_alloc <= st->num + 1) {
        174.           s = OPENSSL_realloc((char *)st->data,
                           ^
        175.                               (unsigned int)sizeof(char *) * st->num_alloc * 2);
        176.           if (s == NULL)

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.   #ifdef CRYPTO_MDEBUG

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

apps/crl2p7.c:139:32: use-after-lifetime part of the trace starts here
137.           case OPT_CERTFILE:
138.               if ((certflst == NULL)
139.                   && (certflst = sk_OPENSSL_STRING_new_null()) == NULL)
                                      ^
140.                   goto end;
141.               if (!sk_OPENSSL_STRING_push(certflst, opt_arg())) {

apps/crl2p7.c:139:32: passed as argument to `sk_OPENSSL_STRING_new_null`
  137.           case OPT_CERTFILE:
  138.               if ((certflst == NULL)
  139.                   && (certflst = sk_OPENSSL_STRING_new_null()) == NULL)
                                        ^
  140.                   goto end;
  141.               if (!sk_OPENSSL_STRING_push(certflst, opt_arg())) {

apps/crl2p7.c:139:32: return from call to `sk_OPENSSL_STRING_new_null`
  137.           case OPT_CERTFILE:
  138.               if ((certflst == NULL)
  139.                   && (certflst = sk_OPENSSL_STRING_new_null()) == NULL)
                                        ^
  140.                   goto end;
  141.               if (!sk_OPENSSL_STRING_push(certflst, opt_arg())) {

apps/crl2p7.c:139:21: assigned
  137.           case OPT_CERTFILE:
  138.               if ((certflst == NULL)
  139.                   && (certflst = sk_OPENSSL_STRING_new_null()) == NULL)
                             ^
  140.                   goto end;
  141.               if (!sk_OPENSSL_STRING_push(certflst, opt_arg())) {

apps/crl2p7.c:142:17: when calling `sk_OPENSSL_STRING_free` here
  140.                   goto end;
  141.               if (!sk_OPENSSL_STRING_push(certflst, opt_arg())) {
  142.                   sk_OPENSSL_STRING_free(certflst);
                         ^
  143.                   goto end;
  144.               }

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

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