apps/engine.c:313: error: USE_AFTER_FREE
  call to `sk_OPENSSL_CSTRING_push()` eventually accesses memory that was invalidated by call to `free()` on line 313 indirectly during the call to `sk_OPENSSL_CSTRING_push()`.
Showing all 24 steps of the trace


apps/engine.c:296:42: invalidation part of the trace starts here
294.       int verbose = 0, list_cap = 0, test_avail = 0, test_avail_noise = 0;
295.       ENGINE *e;
296.       STACK_OF(OPENSSL_CSTRING) *engines = sk_OPENSSL_CSTRING_new_null();
                                                ^
297.       STACK_OF(OPENSSL_STRING) *pre_cmds = sk_OPENSSL_STRING_new_null();
298.       STACK_OF(OPENSSL_STRING) *post_cmds = sk_OPENSSL_STRING_new_null();

apps/engine.c:296:42: passed as argument to `sk_OPENSSL_CSTRING_new_null`
  294.       int verbose = 0, list_cap = 0, test_avail = 0, test_avail_noise = 0;
  295.       ENGINE *e;
  296.       STACK_OF(OPENSSL_CSTRING) *engines = sk_OPENSSL_CSTRING_new_null();
                                                  ^
  297.       STACK_OF(OPENSSL_STRING) *pre_cmds = sk_OPENSSL_STRING_new_null();
  298.       STACK_OF(OPENSSL_STRING) *post_cmds = sk_OPENSSL_STRING_new_null();

apps/engine.c:296:42: return from call to `sk_OPENSSL_CSTRING_new_null`
  294.       int verbose = 0, list_cap = 0, test_avail = 0, test_avail_noise = 0;
  295.       ENGINE *e;
  296.       STACK_OF(OPENSSL_CSTRING) *engines = sk_OPENSSL_CSTRING_new_null();
                                                  ^
  297.       STACK_OF(OPENSSL_STRING) *pre_cmds = sk_OPENSSL_STRING_new_null();
  298.       STACK_OF(OPENSSL_STRING) *post_cmds = sk_OPENSSL_STRING_new_null();

apps/engine.c:296:5: assigned
  294.       int verbose = 0, list_cap = 0, test_avail = 0, test_avail_noise = 0;
  295.       ENGINE *e;
  296.       STACK_OF(OPENSSL_CSTRING) *engines = sk_OPENSSL_CSTRING_new_null();
             ^
  297.       STACK_OF(OPENSSL_STRING) *pre_cmds = sk_OPENSSL_STRING_new_null();
  298.       STACK_OF(OPENSSL_STRING) *post_cmds = sk_OPENSSL_STRING_new_null();

apps/engine.c:313:9: when calling `sk_OPENSSL_CSTRING_push` here
  311.       prog = argv[0];
  312.       while ((argv1 = argv[1]) != NULL && *argv1 != '-') {
  313.           sk_OPENSSL_CSTRING_push(engines, argv1);
                 ^
  314.           argc--;
  315.           argv++;

include/openssl/safestack.h:160:1: parameter `sk` of sk_OPENSSL_CSTRING_push
    158.    */
    159.   DEFINE_SPECIAL_STACK_OF(OPENSSL_STRING, char)
    160. > DEFINE_SPECIAL_STACK_OF_CONST(OPENSSL_CSTRING, char)
    161.   
    162.   /*

include/openssl/safestack.h:160:1: when calling `OPENSSL_sk_push` here
    158.    */
    159.   DEFINE_SPECIAL_STACK_OF(OPENSSL_STRING, char)
    160. > DEFINE_SPECIAL_STACK_OF_CONST(OPENSSL_CSTRING, char)
    161.   
    162.   /*

crypto/stack/stack.c:321:1: parameter `st` of OPENSSL_sk_push
      319.   }
      320.   
      321. > int OPENSSL_sk_push(OPENSSL_STACK *st, const void *data)
      322.   {
      323.       if (st == NULL)

crypto/stack/stack.c:325:12: when calling `OPENSSL_sk_insert` here
      323.       if (st == NULL)
      324.           return -1;
      325.       return OPENSSL_sk_insert(st, data, st->num);
                        ^
      326.   }
      327.   

crypto/stack/stack.c:232:1: parameter `st` of OPENSSL_sk_insert
        230.   }
        231.   
        232. > int OPENSSL_sk_insert(OPENSSL_STACK *st, const void *data, int loc)
        233.   {
        234.       if (st == NULL || st->num == max_nodes)

crypto/stack/stack.c:237:10: when calling `sk_reserve` here
        235.           return 0;
        236.   
        237.       if (!sk_reserve(st, 1, 0))
                        ^
        238.           return 0;
        239.   

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

crypto/stack/stack.c:193:15: when calling `CRYPTO_realloc` here
          191.       }
          192.   
          193.       tmpdata = OPENSSL_realloc((void *)st->data, sizeof(void *) * num_alloc);
                               ^
          194.       if (tmpdata == NULL)
          195.           return 0;

crypto/mem.c:228:1: parameter `str` of CRYPTO_realloc
            226.   }
            227.   
            228. > void *CRYPTO_realloc(void *str, size_t num, const char *file, int line)
            229.   {
            230.       INCREMENT(realloc_count);

crypto/mem.c:239:9: when calling `CRYPTO_free` here
            237.   
            238.       if (num == 0) {
            239.           CRYPTO_free(str, file, line);
                           ^
            240.           return NULL;
            241.       }

crypto/mem.c:286:1: parameter `str` of CRYPTO_free
              284.   }
              285.   
              286. > void CRYPTO_free(void *str, const char *file, int line)
              287.   {
              288.       INCREMENT(free_count);

crypto/mem.c:303:5: was invalidated by call to `free()`
              301.       }
              302.   #else
              303.       free(str);
                         ^
              304.   #endif
              305.   }

apps/engine.c:296:42: use-after-lifetime part of the trace starts here
294.       int verbose = 0, list_cap = 0, test_avail = 0, test_avail_noise = 0;
295.       ENGINE *e;
296.       STACK_OF(OPENSSL_CSTRING) *engines = sk_OPENSSL_CSTRING_new_null();
                                                ^
297.       STACK_OF(OPENSSL_STRING) *pre_cmds = sk_OPENSSL_STRING_new_null();
298.       STACK_OF(OPENSSL_STRING) *post_cmds = sk_OPENSSL_STRING_new_null();

apps/engine.c:296:42: passed as argument to `sk_OPENSSL_CSTRING_new_null`
  294.       int verbose = 0, list_cap = 0, test_avail = 0, test_avail_noise = 0;
  295.       ENGINE *e;
  296.       STACK_OF(OPENSSL_CSTRING) *engines = sk_OPENSSL_CSTRING_new_null();
                                                  ^
  297.       STACK_OF(OPENSSL_STRING) *pre_cmds = sk_OPENSSL_STRING_new_null();
  298.       STACK_OF(OPENSSL_STRING) *post_cmds = sk_OPENSSL_STRING_new_null();

apps/engine.c:296:42: return from call to `sk_OPENSSL_CSTRING_new_null`
  294.       int verbose = 0, list_cap = 0, test_avail = 0, test_avail_noise = 0;
  295.       ENGINE *e;
  296.       STACK_OF(OPENSSL_CSTRING) *engines = sk_OPENSSL_CSTRING_new_null();
                                                  ^
  297.       STACK_OF(OPENSSL_STRING) *pre_cmds = sk_OPENSSL_STRING_new_null();
  298.       STACK_OF(OPENSSL_STRING) *post_cmds = sk_OPENSSL_STRING_new_null();

apps/engine.c:296:5: assigned
  294.       int verbose = 0, list_cap = 0, test_avail = 0, test_avail_noise = 0;
  295.       ENGINE *e;
  296.       STACK_OF(OPENSSL_CSTRING) *engines = sk_OPENSSL_CSTRING_new_null();
             ^
  297.       STACK_OF(OPENSSL_STRING) *pre_cmds = sk_OPENSSL_STRING_new_null();
  298.       STACK_OF(OPENSSL_STRING) *post_cmds = sk_OPENSSL_STRING_new_null();

apps/engine.c:313:9: when calling `sk_OPENSSL_CSTRING_push` here
  311.       prog = argv[0];
  312.       while ((argv1 = argv[1]) != NULL && *argv1 != '-') {
  313.           sk_OPENSSL_CSTRING_push(engines, argv1);
                 ^
  314.           argc--;
  315.           argv++;

crypto/mem.c:286:1: parameter `str` of CRYPTO_free
    284.   }
    285.   
    286. > void CRYPTO_free(void *str, const char *file, int line)
    287.   {
    288.       INCREMENT(free_count);

crypto/mem.c:303:5: invalid access occurs here
    301.       }
    302.   #else
    303.       free(str);
               ^
    304.   #endif
    305.   }
