crypto/ex_data.c:326: error: USE_AFTER_FREE
  call to `CRYPTO_set_ex_data()` eventually accesses memory that was invalidated by call to `free()` on line 326 indirectly during the call to `CRYPTO_set_ex_data()`.
Showing all 26 steps of the trace


crypto/ex_data.c:268:1: invalidation part of the trace starts here
266.    * for each index in the class used by this variable
267.    */
268. > int CRYPTO_dup_ex_data(int class_index, CRYPTO_EX_DATA *to,
269.                          const CRYPTO_EX_DATA *from)
270.   {

crypto/ex_data.c:268:1: parameter `to` of CRYPTO_dup_ex_data
  266.    * for each index in the class used by this variable
  267.    */
  268. > int CRYPTO_dup_ex_data(int class_index, CRYPTO_EX_DATA *to,
  269.                          const CRYPTO_EX_DATA *from)
  270.   {

crypto/ex_data.c:326:9: when calling `CRYPTO_set_ex_data` here
  324.                                         storage[i]->argl, storage[i]->argp))
  325.                   goto err;
  326.           CRYPTO_set_ex_data(to, i, ptr);
                 ^
  327.       }
  328.       toret = 1;

crypto/ex_data.c:433:1: parameter `ad` of CRYPTO_set_ex_data
    431.    * particular index in the class used by this variable
    432.    */
    433. > int CRYPTO_set_ex_data(CRYPTO_EX_DATA *ad, int idx, void *val)
    434.   {
    435.       int i;

crypto/ex_data.c:445:14: when calling `sk_void_push` here
    443.   
    444.       for (i = sk_void_num(ad->sk); i <= idx; ++i) {
    445.           if (!sk_void_push(ad->sk, NULL)) {
                        ^
    446.               CRYPTOerr(CRYPTO_F_CRYPTO_SET_EX_DATA, ERR_R_MALLOC_FAILURE);
    447.               return 0;

include/openssl/crypto.h:90:1: parameter `sk` of sk_void_push
      88.       STACK_OF(void) *sk;
      89.   };
      90. > DEFINE_STACK_OF(void)
      91.   
      92.   /*

include/openssl/crypto.h:90:1: when calling `OPENSSL_sk_push` here
      88.       STACK_OF(void) *sk;
      89.   };
      90. > DEFINE_STACK_OF(void)
      91.   
      92.   /*

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

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

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

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

crypto/stack/stack.c:159:1: parameter `st` of sk_reserve
            157.   
            158.   /* internal STACK storage allocation */
            159. > static int sk_reserve(OPENSSL_STACK *st, int n, int exact)
            160.   {
            161.       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: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/ex_data.c:268:1: use-after-lifetime part of the trace starts here
266.    * for each index in the class used by this variable
267.    */
268. > int CRYPTO_dup_ex_data(int class_index, CRYPTO_EX_DATA *to,
269.                          const CRYPTO_EX_DATA *from)
270.   {

crypto/ex_data.c:268:1: parameter `to` of CRYPTO_dup_ex_data
  266.    * for each index in the class used by this variable
  267.    */
  268. > int CRYPTO_dup_ex_data(int class_index, CRYPTO_EX_DATA *to,
  269.                          const CRYPTO_EX_DATA *from)
  270.   {

crypto/ex_data.c:326:9: when calling `CRYPTO_set_ex_data` here
  324.                                         storage[i]->argl, storage[i]->argp))
  325.                   goto err;
  326.           CRYPTO_set_ex_data(to, i, ptr);
                 ^
  327.       }
  328.       toret = 1;

crypto/ex_data.c:433:1: parameter `ad` of CRYPTO_set_ex_data
    431.    * particular index in the class used by this variable
    432.    */
    433. > int CRYPTO_set_ex_data(CRYPTO_EX_DATA *ad, int idx, void *val)
    434.   {
    435.       int i;

crypto/ex_data.c:450:5: when calling `sk_void_set` here
    448.           }
    449.       }
    450.       sk_void_set(ad->sk, idx, val);
               ^
    451.       return 1;
    452.   }

include/openssl/crypto.h:90:1: parameter `sk` of sk_void_set
      88.       STACK_OF(void) *sk;
      89.   };
      90. > DEFINE_STACK_OF(void)
      91.   
      92.   /*

include/openssl/crypto.h:90:1: when calling `OPENSSL_sk_set` here
      88.       STACK_OF(void) *sk;
      89.   };
      90. > DEFINE_STACK_OF(void)
      91.   
      92.   /*

crypto/stack/stack.c:391:1: parameter `st` of OPENSSL_sk_set
        389.   }
        390.   
        391. > void *OPENSSL_sk_set(OPENSSL_STACK *st, int i, const void *data)
        392.   {
        393.       if (st == NULL || i < 0 || i >= st->num)

crypto/stack/stack.c:397:20: invalid access occurs here
        395.       st->data[i] = data;
        396.       st->sorted = 0;
        397.       return (void *)st->data[i];
                                  ^
        398.   }
        399.   
