crypto/crmf/crmf_lib.c:377: error: USE_AFTER_FREE
  call to `sk_X509_EXTENSION_free()` eventually accesses memory that was invalidated by call to `free()` on line 370 indirectly during the call to `sk_X509_EXTENSION_push()`.
Showing all 24 steps of the trace


crypto/crmf/crmf_lib.c:365:33: invalidation part of the trace starts here
363.   
364.       if (tmpl->extensions == NULL) {
365.           if ((tmpl->extensions = sk_X509_EXTENSION_new_null()) == NULL)
                                       ^
366.               goto oom;
367.           new = 1;

crypto/crmf/crmf_lib.c:365:33: passed as argument to `sk_X509_EXTENSION_new_null`
  363.   
  364.       if (tmpl->extensions == NULL) {
  365.           if ((tmpl->extensions = sk_X509_EXTENSION_new_null()) == NULL)
                                         ^
  366.               goto oom;
  367.           new = 1;

crypto/crmf/crmf_lib.c:365:33: return from call to `sk_X509_EXTENSION_new_null`
  363.   
  364.       if (tmpl->extensions == NULL) {
  365.           if ((tmpl->extensions = sk_X509_EXTENSION_new_null()) == NULL)
                                         ^
  366.               goto oom;
  367.           new = 1;

crypto/crmf/crmf_lib.c:365:14: assigned
  363.   
  364.       if (tmpl->extensions == NULL) {
  365.           if ((tmpl->extensions = sk_X509_EXTENSION_new_null()) == NULL)
                      ^
  366.               goto oom;
  367.           new = 1;

crypto/crmf/crmf_lib.c:370:10: when calling `sk_X509_EXTENSION_push` here
  368.       }
  369.   
  370.       if (!sk_X509_EXTENSION_push(tmpl->extensions, (X509_EXTENSION *)ext))
                  ^
  371.           goto oom;
  372.       return 1;

include/openssl/x509.h:85:1: parameter `sk` of sk_X509_EXTENSION_push
    83.   typedef STACK_OF(X509_EXTENSION) X509_EXTENSIONS;
    84.   
    85. > DEFINE_STACK_OF(X509_EXTENSION)
    86.   
    87.   typedef struct x509_attributes_st X509_ATTRIBUTE;

include/openssl/x509.h:85:1: when calling `OPENSSL_sk_push` here
    83.   typedef STACK_OF(X509_EXTENSION) X509_EXTENSIONS;
    84.   
    85. > DEFINE_STACK_OF(X509_EXTENSION)
    86.   
    87.   typedef struct x509_attributes_st X509_ATTRIBUTE;

crypto/stack/stack.c:326:1: parameter `st` of OPENSSL_sk_push
      324.   }
      325.   
      326. > int OPENSSL_sk_push(OPENSSL_STACK *st, const void *data)
      327.   {
      328.       if (st == NULL)

crypto/stack/stack.c:330:12: when calling `OPENSSL_sk_insert` here
      328.       if (st == NULL)
      329.           return -1;
      330.       return OPENSSL_sk_insert(st, data, st->num);
                        ^
      331.   }
      332.   

crypto/stack/stack.c:237:1: parameter `st` of OPENSSL_sk_insert
        235.   }
        236.   
        237. > int OPENSSL_sk_insert(OPENSSL_STACK *st, const void *data, int loc)
        238.   {
        239.       if (st == NULL || st->num == max_nodes)

crypto/stack/stack.c:242:10: when calling `sk_reserve` here
        240.           return 0;
        241.   
        242.       if (!sk_reserve(st, 1, 0))
                        ^
        243.           return 0;
        244.   

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

crypto/mem.c:238:1: parameter `str` of CRYPTO_realloc
            236.   }
            237.   
            238. > void *CRYPTO_realloc(void *str, size_t num, const char *file, int line)
            239.   {
            240.       INCREMENT(realloc_count);

crypto/mem.c:249:9: when calling `CRYPTO_free` here
            247.   
            248.       if (num == 0) {
            249.           CRYPTO_free(str, file, line);
                           ^
            250.           return NULL;
            251.       }

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

crypto/crmf/crmf_lib.c:365:33: use-after-lifetime part of the trace starts here
363.   
364.       if (tmpl->extensions == NULL) {
365.           if ((tmpl->extensions = sk_X509_EXTENSION_new_null()) == NULL)
                                       ^
366.               goto oom;
367.           new = 1;

crypto/crmf/crmf_lib.c:365:33: passed as argument to `sk_X509_EXTENSION_new_null`
  363.   
  364.       if (tmpl->extensions == NULL) {
  365.           if ((tmpl->extensions = sk_X509_EXTENSION_new_null()) == NULL)
                                         ^
  366.               goto oom;
  367.           new = 1;

crypto/crmf/crmf_lib.c:365:33: return from call to `sk_X509_EXTENSION_new_null`
  363.   
  364.       if (tmpl->extensions == NULL) {
  365.           if ((tmpl->extensions = sk_X509_EXTENSION_new_null()) == NULL)
                                         ^
  366.               goto oom;
  367.           new = 1;

crypto/crmf/crmf_lib.c:365:14: assigned
  363.   
  364.       if (tmpl->extensions == NULL) {
  365.           if ((tmpl->extensions = sk_X509_EXTENSION_new_null()) == NULL)
                      ^
  366.               goto oom;
  367.           new = 1;

crypto/crmf/crmf_lib.c:377:9: when calling `sk_X509_EXTENSION_free` here
  375.   
  376.       if (new != 0) {
  377.           sk_X509_EXTENSION_free(tmpl->extensions);
                 ^
  378.           tmpl->extensions = NULL;
  379.       }

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