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


apps/speed.c:1258:1: invalidation part of the trace starts here
1256.   
1257.   static long eddsa_c[EdDSA_NUM][2];
1258. > static int EdDSA_sign_loop(void *args)
1259.   {
1260.       loopargs_t *tempargs = *(loopargs_t **) args;

apps/speed.c:1258:1: parameter `args` of EdDSA_sign_loop
  1256.   
  1257.   static long eddsa_c[EdDSA_NUM][2];
  1258. > static int EdDSA_sign_loop(void *args)
  1259.   {
  1260.       loopargs_t *tempargs = *(loopargs_t **) args;

apps/speed.c:1260:5: assigned
  1258.   static int EdDSA_sign_loop(void *args)
  1259.   {
  1260.       loopargs_t *tempargs = *(loopargs_t **) args;
              ^
  1261.       unsigned char *buf = tempargs->buf;
  1262.       EVP_MD_CTX **edctx = tempargs->eddsa_ctx;

apps/speed.c:1262:5: assigned
  1260.       loopargs_t *tempargs = *(loopargs_t **) args;
  1261.       unsigned char *buf = tempargs->buf;
  1262.       EVP_MD_CTX **edctx = tempargs->eddsa_ctx;
              ^
  1263.       unsigned char *eddsasig = tempargs->buf2;
  1264.       size_t *eddsasigsize = &tempargs->sigsize;

apps/speed.c:1268:15: when calling `EVP_DigestSign` here
  1266.   
  1267.       for (count = 0; COND(eddsa_c[testnum][0]); count++) {
  1268.           ret = EVP_DigestSign(edctx[testnum], eddsasig, eddsasigsize, buf, 20);
                        ^
  1269.           if (ret == 0) {
  1270.               BIO_printf(bio_err, "EdDSA sign failure\n");

crypto/evp/m_sigver.c:163:1: parameter `ctx` of EVP_DigestSign
    161.   }
    162.   
    163. > int EVP_DigestSign(EVP_MD_CTX *ctx, unsigned char *sigret, size_t *siglen,
    164.                      const unsigned char *tbs, size_t tbslen)
    165.   {

crypto/evp/m_sigver.c:170:12: when calling `EVP_DigestSignFinal` here
    168.       if (sigret != NULL && EVP_DigestSignUpdate(ctx, tbs, tbslen) <= 0)
    169.           return 0;
    170.       return EVP_DigestSignFinal(ctx, sigret, siglen);
                      ^
    171.   }
    172.   

crypto/evp/m_sigver.c:100:1: parameter `ctx` of EVP_DigestSignFinal
      98.   }
      99.   
      100. > int EVP_DigestSignFinal(EVP_MD_CTX *ctx, unsigned char *sigret,
      101.                           size_t *siglen)
      102.   {

crypto/evp/m_sigver.c:130:21: when calling `EVP_DigestFinal_ex` here
      128.                   r = ctx->pctx->pmeth->signctx(ctx->pctx, sigret, siglen, ctx);
      129.               else
      130.                   r = EVP_DigestFinal_ex(ctx, md, &mdlen);
                                 ^
      131.           } else {
      132.               EVP_MD_CTX *tmp_ctx = EVP_MD_CTX_new();

crypto/evp/digest.c:312:1: parameter `ctx` of EVP_DigestFinal_ex
        310.   
        311.   /* The caller can assume that this removes any secret data from the context */
        312. > int EVP_DigestFinal_ex(EVP_MD_CTX *ctx, unsigned char *md, unsigned int *isize)
        313.   {
        314.       int ret;

crypto/evp/digest.c:337:5: when calling `EVP_MD_CTX_reset` here
        335.       }
        336.   
        337.       EVP_MD_CTX_reset(ctx);
                   ^
        338.       return ret;
        339.   

crypto/evp/digest.c:22:1: parameter `ctx` of EVP_MD_CTX_reset
          20.   
          21.   /* This call frees resources associated with the context */
          22. > int EVP_MD_CTX_reset(EVP_MD_CTX *ctx)
          23.   {
          24.       if (ctx == NULL)

crypto/evp/digest.c:54:9: when calling `CRYPTO_clear_free` here
          52.       if (ctx->digest && ctx->digest->ctx_size && ctx->md_data
          53.           && !EVP_MD_CTX_test_flags(ctx, EVP_MD_CTX_FLAG_REUSE)) {
          54.           OPENSSL_clear_free(ctx->md_data, ctx->digest->ctx_size);
                        ^
          55.       }
          56.       /*

crypto/mem.c:316:1: parameter `str` of CRYPTO_clear_free
            314.   }
            315.   
            316. > void CRYPTO_clear_free(void *str, size_t num, const char *file, int line)
            317.   {
            318.       if (str == NULL)

crypto/mem.c:322:5: when calling `CRYPTO_free` here
            320.       if (num)
            321.           OPENSSL_cleanse(str, num);
            322.       CRYPTO_free(str, file, line);
                       ^
            323.   }

crypto/mem.c:295:1: parameter `str` of CRYPTO_free
              293.   }
              294.   
              295. > void CRYPTO_free(void *str, const char *file, int line)
              296.   {
              297.       INCREMENT(free_count);

crypto/mem.c:312:5: was invalidated by call to `free()`
              310.       }
              311.   #else
              312.       free(str);
                         ^
              313.   #endif
              314.   }

apps/speed.c:1258:1: use-after-lifetime part of the trace starts here
1256.   
1257.   static long eddsa_c[EdDSA_NUM][2];
1258. > static int EdDSA_sign_loop(void *args)
1259.   {
1260.       loopargs_t *tempargs = *(loopargs_t **) args;

apps/speed.c:1258:1: parameter `args` of EdDSA_sign_loop
  1256.   
  1257.   static long eddsa_c[EdDSA_NUM][2];
  1258. > static int EdDSA_sign_loop(void *args)
  1259.   {
  1260.       loopargs_t *tempargs = *(loopargs_t **) args;

apps/speed.c:1260:5: assigned
  1258.   static int EdDSA_sign_loop(void *args)
  1259.   {
  1260.       loopargs_t *tempargs = *(loopargs_t **) args;
              ^
  1261.       unsigned char *buf = tempargs->buf;
  1262.       EVP_MD_CTX **edctx = tempargs->eddsa_ctx;

apps/speed.c:1262:5: assigned
  1260.       loopargs_t *tempargs = *(loopargs_t **) args;
  1261.       unsigned char *buf = tempargs->buf;
  1262.       EVP_MD_CTX **edctx = tempargs->eddsa_ctx;
              ^
  1263.       unsigned char *eddsasig = tempargs->buf2;
  1264.       size_t *eddsasigsize = &tempargs->sigsize;

apps/speed.c:1268:15: when calling `EVP_DigestSign` here
  1266.   
  1267.       for (count = 0; COND(eddsa_c[testnum][0]); count++) {
  1268.           ret = EVP_DigestSign(edctx[testnum], eddsasig, eddsasigsize, buf, 20);
                        ^
  1269.           if (ret == 0) {
  1270.               BIO_printf(bio_err, "EdDSA sign failure\n");

crypto/mem.c:295:1: parameter `str` of CRYPTO_free
    293.   }
    294.   
    295. > void CRYPTO_free(void *str, const char *file, int line)
    296.   {
    297.       INCREMENT(free_count);

crypto/mem.c:312:5: invalid access occurs here
    310.       }
    311.   #else
    312.       free(str);
               ^
    313.   #endif
    314.   }
